Most portable way to resample image?
Posted: 2009-05-26T11:11:40-07:00
The application I am writing depends on relatively consistent output from the resample function. I need to be able to, as portably as possible, resample an image from 600 to 100 dpi. I do not want to mandate the user have a particlar version which may not be bundled with their distro. As such, I need to create consistent output with as many versions of ImageMagick as possible, and I am having issues...
Using version: "6.5.2-2 2009-05-06 Q16 HDRI"
This Command line:
Produces the same output (close enough for me) as this Perl Code:
Yet on another machine, (Version "6.4.4 2009-02-13 Q16 HDRI") the output from the perl code is very different.
In particular, it appears the "filter" and/or "blur" settings are being ignored. (Which may be a bug in that version... but that doesn't help me much.)
If need be, I can write a C program (using the API) to do this, but I would rather not, as most of my code is Perl already. However, If I can guarantee that the output will be consistent, then it would be worth it.
Does The behavior of the command line change regularly? Does it diverge from the perl and C APIs often? or is this diversion a Bug? If I write some C code to do this, am I going to have the same problem as I have with the Perl API? (i.e. Output differing significantly from version to version?)
Thanks for the help.
Jonathan
Using version: "6.5.2-2 2009-05-06 Q16 HDRI"
This Command line:
Code: Select all
convert large.png -resample 100 small.png
Code: Select all
$image = Image::Magick->new;
$image->Read('large.png');
$image->Set(units=>'PixelsPerInch');
$image->Set(density=>600);
$image->Resample(density=>100},
filter=>'Lanczos',
blur=>0.5);
$image->Set(depth=>8);
$image->Write(filename=>'small.png');
In particular, it appears the "filter" and/or "blur" settings are being ignored. (Which may be a bug in that version... but that doesn't help me much.)
If need be, I can write a C program (using the API) to do this, but I would rather not, as most of my code is Perl already. However, If I can guarantee that the output will be consistent, then it would be worth it.
Does The behavior of the command line change regularly? Does it diverge from the perl and C APIs often? or is this diversion a Bug? If I write some C code to do this, am I going to have the same problem as I have with the Perl API? (i.e. Output differing significantly from version to version?)
Thanks for the help.
Jonathan