fax tiff to jpg, dealing with multiple resolutions

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
mmlenz
Posts: 23
Joined: 2012-05-30T08:08:21-07:00
Authentication code: 13

fax tiff to jpg, dealing with multiple resolutions

Post by mmlenz »

I'm using:

convert -quiet source.tif -resize 400x400 low-%d.jpg

(with the above I'm using -resize 400x400 to limit the max width/height of the resulting image)

To convert the following:

source-A.tif
Geometry: 1728x2135+0+0
Resolution: 204x196

source-B.tif
Geometry: 1728x1097+0+0
Resolution: 204x98

source-A.tif generates low resolution preview jpgs that look correct, but souce-B.tif produces previews that are squashed vertically. I can use -resize 100x200%! to help with the problem with source-B.tif but then source-A.tif is now vertically stretched.

Is there a single convert command line that can "just work" for both?

Thanks guys.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fax tiff to jpg, dealing with multiple resolutions

Post by fmw42 »

-resize 400x400 should produce images that preserve the aspect ratio and not distort the image. The result will resize the larger of your image dimensions to 400 and the other will scaled according to the aspect ratio.

I suspect you have a bug or problem with one of your input images. Does either of your images have a virtual canvas that is larger than your image size? Try adding +repage right after reading the input and before the -resize.

What version of IM and platform are you using?

Can you post a link to you input images? Post them on a free image hosting service and put a link here.
mmlenz
Posts: 23
Joined: 2012-05-30T08:08:21-07:00
Authentication code: 13

Re: fax tiff to jpg, dealing with multiple resolutions

Post by mmlenz »

fmw42 wrote:-resize 400x400 should produce images that preserve the aspect ratio and not distort the image. The result will resize the larger of your image dimensions to 400 and the other will scaled according to the aspect ratio.

I suspect you have a bug or problem with one of your input images. Does either of your images have a virtual canvas that is larger than your image size? Try adding +repage right after reading the input and before the -resize.

What version of IM and platform are you using?

Can you post a link to you input images? Post them on a free image hosting service and put a link here.
Fax tiffs are strange sometimes. You'll get some that are around 200x200 resolution and others that are around 200x100. You have to correct for those by doubling the height. I'm just trying to figure out a way to have it work for those as well as images with similar width/height resolutions all in one convert command. Otherwise I'm going to have to do an identify and parse out the resolution and if it's wonkey , prepend the -resize 100x200%!

$ identify -version
Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

It's running on Debian Squeeze 6.x
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fax tiff to jpg, dealing with multiple resolutions

Post by fmw42 »

See -resample, it takes the density (dpi) into account.

http://www.imagemagick.org/script/comma ... p#resample
mmlenz
Posts: 23
Joined: 2012-05-30T08:08:21-07:00
Authentication code: 13

Re: fax tiff to jpg, dealing with multiple resolutions

Post by mmlenz »

WORKS! Thanks so much! Since these are just thumbnails and image previews I will use -resample 200
Post Reply