only shrink larger predictably no-op with -distort Resize

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
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

only shrink larger predictably no-op with -distort Resize

Post by NicolasRobidoux »

Part 1
What is the simplest way to get convert (or magick) to behave as follows? I would like

Code: Select all

convert (or magick) input.img -distort Resize bigxbig\> output.img
to be a no-op when the input image is small enough to fit in bigxbig.
This is what happens if I use convert -resize instead of convert -distort Resize. So, I basically am asking how I can get the same "no-op" behavior with -distort Resize. Of course, when downsampling an image without transparency, the default filter is Lanczos for -resize, which is interpolatory, and consequently would give a result which is less different from the no-op result than the default -distort Resize filter, namely Robidoux.
I do not want to swith to an interpolatory filter with -distort Resize (like Triangle).

Part 2
Same question if I use a named filter, that is, if I insert "-filter LanczosSharp" before "-distort Resize"?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: only shrink larger predictably no-op with -distort Resiz

Post by anthony »

Resize noop only
1/ the result of the geometry is the same and the image size (that is what \> flag does )
2/ the default filter is used.

That is is you use gaussian filter in resize the image will be blurred a bit even if the image does not change size.

Distort resize just misses point 2. It always applied basically as all filters 'blur' a little even for a no-op resize.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: only shrink larger predictably no-op with -distort Resiz

Post by NicolasRobidoux »

Basically, my question was:
Given what you just stated, what's the simplest way to get what I want.
-----
This being said, I don't need it badly.
If I needed it badly, I'd write something that explicitly checks the dimensions and skips the resampling filter if the output dimensions are the same as the input dimensions.
My guess is that this should be pretty easy to write.
Post Reply