Using Filters for 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
vmpre
Posts: 5
Joined: 2011-02-17T15:37:30-07:00
Authentication code: 8675308

Using Filters for resizing

Post by vmpre »

Hey everyone

Newb here.

Been experimenting with IM for some image resizing that I need to do.

My input image is 4096x4096 that I am resizing to 1024x1024 and I would like to experiment with different filters to see what results I get.

I am doing two conversions to do a comparison of the results

Control Test:

Code: Select all

convert.exe input.psd[0] -colorspace LAB -resize 1024x1024 -colorspace sRGB output.tif
Filter Test:

Code: Select all

convert.exe input.psd[0] -colorspace LAB -filter Lanczos -resize 1024x1024 -colorspace sRGB output_lanczos.tif
The thing is...I dont notice a difference between the two results. They are completely identical.

For that matter most of the Windowed filters seem to have no effect at all.The other filters like point and gaussian do yield different results.

Using ImageMagick-7.0.2-Q16-HDRI

Unfortunately I am unable to post my source image as it is a protected image. Sorry! :(

Am I missing something?

Thanks for any guidance!

Cheers!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using Filters for resizing

Post by snibgo »

vmpre wrote:Am I missing something?
Yes. See http://www.imagemagick.org/script/comma ... php#filter :
If you do not select a filter with this option, the filter defaults to Mitchell for a colormapped image, an image with a matte channel, or if the image is enlarged. Otherwise the filter default to Lanczos.
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Using Filters for resizing

Post by Bonzo »

The filters can have more effect on some images than others; depending on the subject.

This is some php code I wrote a while ago that used to resize an image with all the available filters. With IM version 7 you may need to change convert to magick.

Code: Select all

<?php 
// Build the array of filters to be used  
exec("convert -list filter", $IMarray, $code);  
// Start the loop to resize with the different filters  
foreach ($IMarray as $value) {  
$new_name = $value."_resize.png";  
exec ("convert input.png -filter $value -resize 300x300 -bordercolor black -border 1x1 $new_name");  
echo "<tr><td><img src=\"".$new_name."\"></td>";  
echo "<td>$value</td></tr>";  
}  
?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using Filters for resizing

Post by fmw42 »

vmpre
Posts: 5
Joined: 2011-02-17T15:37:30-07:00
Authentication code: 8675308

Re: Using Filters for resizing

Post by vmpre »

Thanks everyone!

That helped a lot. I think I have it now.

Set up a little bat file that spit out images with all the different filters. Some of them (at least on the image I was testing) had almost imperceptible differences in them. Had to zoom in about 1200% in some cases to even see anything.

Cheers that helped!
Post Reply