I'm using Perl and the Image::Magick module to process some JPEGs.
I'm using the GetPixels sub to get the RGB components of each pixel.
e.g.
my @pixels = $img->GetPixels(
width => 1,
height => 1,
x => 0,
y => 0,
map => 'RGB',
#normalize => 1
)
print Dumper \@pixels;
$img->Resize(
width => 1,
height => 1,
filter => 'Lanczos'
);
@pixels = $img->GetPixels(
width => 1,
height => 1,
x => 0,
y => 0,
map => 'RGB',
#normalize => 1
);
print Dumper \@pixels;
$img->Write('verify.jpg');
I've found that getPixels is returning two bytes per channel, e.g.
$VAR1 = [
46260,
45232,
44975
];
$VAR1 = [
58271,
58949,
60330
];
Before the call to Resize: (in this example) the colour of the designated pixel is #b4b0af, and the returned values are 0xB4B4, 0xB0B0, 0xAFAF. I don't understand why this is, but I can deal with it using MOD 256;
But after the call to Resize, the returned values don't correspond in any obvious way to the actual values I find in the output file (verify.jpg).
Is Image::Magick just being super-precise (accounting for the shorts instead of bytes)?
And does the JPEG compression account for the discrepancy between the second Dumper output and the contents of 'verify.jpg'?