[SOLVED] using a resize filter without resizing

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

[SOLVED] using a resize filter without resizing

Post by NicolasRobidoux »

What is the easiest way to apply a resizing filter (like the ones used by -resize and -distort Resize) to an image without resizing it?
Using -resize and -distort Resize does not do, because TTBOMK if the input and output sizes are the same, the transformation is short circuited to the identity.
The reason I'm asking is that digital photographers would like to filter out moire from the images obtained out of camera, and I suspect that pushing the result through, say, the EWA LanczosSharp filter, or some other cylindrical windowed Jinc filter, without resizing, may be helpful.
P.S. Not that anybody asked, but I've never liked that there is a short circuit when the resize is trivial.
Last edited by NicolasRobidoux on 2012-11-10T11:27:59-07:00, edited 1 time in total.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: using a resize filter without resizing

Post by glennrp »

In resize.c:ResizeImage(), the shortcut is avoided if filter != UndefinedFilter, so using the "-filter <somefilter>" ahead of "-resize <geometry>" ought to do what you want.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: [SOLVED] using a resize filter without resizing

Post by NicolasRobidoux »

Thank you Glenn.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: using a resize filter without resizing

Post by anthony »

glennrp wrote:In resize.c:ResizeImage(), the shortcut is avoided if filter != UndefinedFilter, so using the "-filter <somefilter>" ahead of "-resize <geometry>" ought to do what you want.
That is very useful to know! I didn't and I saw the code!

Added the following to the opening notes for Resize Operator
First a small point...
Resize will no nothing itself if the resized image is the same.
The exception to this (there is always an exception) is if you actually specify a Resampling Filter. That is the you give a "-filter" setting, to override normal behaviour. Note however that many filters (even the default filters) can blur images slightly. It is part of there nature. So this default is actually a good thing.
See http://www.imagemagick.org/Usage/resize/#resize (in a few hours)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply