TIF Convert - LZW to Group 4 Image Quality

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tpq248
Posts: 3
Joined: 2018-02-15T13:20:21-07:00
Authentication code: 1152

TIF Convert - LZW to Group 4 Image Quality

Post by tpq248 »

Good afternoon! I'm using IM 7.0.7-22 Q16 to convert the compression of TIFF files from LZW to Group 4 with the "-compress Group4" option, but I'm losing some image quality in the process. I've tried adding "-density 600" and "-quality 100" to the command, with no effect.

Unfortunately, these documents are school admissions documents with lots of small text, so I need to keep them as clear as possible - are there other options or tricks I could try that might help? Thanks in advance! --Mark
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF Convert - LZW to Group 4 Image Quality

Post by fmw42 »

Group4 is a black/white fax document and will have less quality than LZW. If you want, post your input TIFF to some free hosting service such as dropbox.com and put the URL here, so we can review your image and do some testing. Also please say what your platform/OS is.

Changing density will make no difference in the image quality until it is printed and then it will only change the size in inches.
tpq248
Posts: 3
Joined: 2018-02-15T13:20:21-07:00
Authentication code: 1152

Re: TIF Convert - LZW to Group 4 Image Quality

Post by tpq248 »

Thanks for the quick reply - the documents I'm working with have sensitive information, but the image file that comes with Windows' fax services shows the same loss when converted - you can see them at this link:

https://www.dropbox.com/sh/gzhyax3666rn ... olyEa?dl=0

My platform is Windows 7, and I used this command to create the converted image:

magick convert c:\Testing\LZW.tif -compress Group4 c:\Testing\Group4.tif

The department is currently downloading the documents from a third party service (which only provides LZW-compressed images), then printing and scanning them - I've written a Powershell script to set up a direct import into the repository (which requires CCITT Group 4). Thanks again for any suggestions you can provide! --Mark
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF Convert - LZW to Group 4 Image Quality

Post by fmw42 »

That is going to happen. Your original is 24-bit total color per pixel image with 384 different colors (mostly grays). When you go to group4, you are converting to binary 1-bit total color per pixel image. So you are losing a lot of color information and quality.

Density does nothing to help a raster image. It only affects the printed output size.

Try threshold -- vary the threshold value as desired.

Code: Select all

magick LZW.tif -threshold 75% -compress group4 result.tif
Note for IM 7 use magick, not magick convert.
tpq248
Posts: 3
Joined: 2018-02-15T13:20:21-07:00
Authentication code: 1152

Re: TIF Convert - LZW to Group 4 Image Quality

Post by tpq248 »

Thank you for the great advice! Threshold values around 30-40% seem to work best for the downloaded student documents - I guess my sample that I provided wasn't as similar to the actual docs as I thought.

I do have one other quick question that I haven't found in the forum - when converting the student documents I need to add the "-negate" switch to prevent me from getting a negative, and now that I'm thinking about it, I think it happens to the student documents but not any of the LZW-compressed samples I pull out of Windows. Is it possible that there is some property of these documents that is the cause?

I've asked the third-party whether they can send me a sample TIFF that contains no sensitive information - I'll let you know if I get it. Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF Convert - LZW to Group 4 Image Quality

Post by fmw42 »

Those reversed files probably have tiff:polarity=min-is-white rather than polarity=min-is-black

Use -define quantum:polarity=min-is-black or -define quantum:polarity=min-is-white to toggle the photometric interpretation for a bilevel image.
Post Reply