resample does not honor "only shrink larger"

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
figge21
Posts: 4
Joined: 2012-09-12T00:11:44-07:00
Authentication code: 67789

resample does not honor "only shrink larger"

Post by figge21 »

I have an issue with resampling.

I cannot get -resample to prohibit upsampling.

I am trying the following:

Code: Select all

convert "infile.psd"[0] -resample 300x300> "outfile.tif"
since I only want to downsample very high resolution files and leave lower resolution files untouched.

Upsampling is usually a bad thing for quality, but in this case it is also murder for the server since the upsampling process can easily run away with all the memory, disk space and cycles.
Large camera images may come in as 4000x5000 at 72 dpi and the upsampling produces enormous images.

I am aware that resample is a wrapper on resize.
I am afraid that the constraint flags may simply be ignored by the wrapper.
Since I have not found any documentation expressing this limitation I would consider it a bug.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resample does not honor "only shrink larger"

Post by anthony »

I do not believe those flags are honored by resample at this time.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
figge21
Posts: 4
Joined: 2012-09-12T00:11:44-07:00
Authentication code: 67789

Re: resample does not honor "only shrink larger"

Post by figge21 »

Is this something you would consider fixing/adding in the near future?

Me no -- I have enough to do. But it is possible that "Magick" would.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resample does not honor "only shrink larger"

Post by fmw42 »

You can achieve the same results by appropriately using -density and -resize. That way -resize will honor the ">" syntax.

I also think that you may get a better quality using -resize.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resample does not honor "only shrink larger"

Post by anthony »

fmw42 wrote:You can achieve the same results by appropriately using -density and -resize. That way -resize will honor the ">" syntax.

I also think that you may get a better quality using -resize.
Thay call the same function, just handle arguments differently, with -resample adjusting density too.

-resample can not use resizes argument handler, as that looks at actual pixel sizes. Now if resample did its size calculations, but then feeds them to resize argument handler, then the flags would be obeyed. But what if the resize was aborted, then the density substitution would also need to be aborted. No that gets messy. Resample would need its own version of flag handling as it maps its arguments to final image size for the lower level ResizeImage core library function.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
figge21
Posts: 4
Joined: 2012-09-12T00:11:44-07:00
Authentication code: 67789

Re: resample does not honor "only shrink larger"

Post by figge21 »

I know that I could rework the command to substitute -resample with -density and -resize/-geometry but since I never know the properties of incoming images in advance I would need to interrogate each image in order to build an appropriate command.
-resample is a wonderful shortcut that would allow me to batch any set of images through with a predictable outcome if only I could suppress upsampling.
Post Reply