Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Bits/sample must be 1 for Group 3/4 encoding/decoding error for b-w colourspace image on ccittfax4 compression #4491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eduardrudko opened this issue Apr 30, 2025 · 1 comment

Comments

@eduardrudko
Copy link

I'm not sure whether i'm doing something wrong or it is a bug. I'm running vips vips-8.9.1-Sun on aarch64 ubuntu. I'm trying to compress tiff image using ccittfax4 algorithm, which requires the input image to be black & white. Here what i'm doing:

vips pdfload input.pdf output1.v --n -1
vips colourspace output1.v output2.v b-w
vips tiffsave output2.v result.tiff --compression ccittfax4

on third command i'm getting:

Fax3SetupState: Bits/sample must be 1 for Group 3/4 encoding/decoding
wbuffer_write: write failed
unix error: Unknown error -1

Which is unexpected for me because the input image is black & white. Any help?

@jcupitt
Copy link
Member

jcupitt commented Apr 30, 2025

Hello @eduardrudko,

PDF images have transparency:

$ vips colourspace thesis.pdf x.v b-w
$ vipsheader x.v
x.v: 595x842 uchar, 2 bands, b-w, pdfload

ie. you have an 8-bit GA (grey plus alpha) image. You need to drop the alpha with eg. flatten against white:

$ vips flatten x.v x2.v --background 255

Then when saving you need to ask tiffsave to save the 8-bit image as 1-bit:

$ vips tiffsave x2.v x.tif --bitdepth 1 --compression ccittfax4

Other savers (eg. the JPEG saver) will flatten for you if you pass an image with alpha, but of course TIFF supports everything (except ccittfax4 compression with alpha!), so it doesn't do much automatic conversion for you.

Perhaps selecting ccittfax4 compression should automatically convert to b-w, flatten, and set bitdepth to 1? Something for the todo list.

@libvips libvips locked and limited conversation to collaborators Apr 30, 2025
@jcupitt jcupitt converted this issue into discussion #4492 Apr 30, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants