Using the image array vs. the root image for attributes
Posted: 2014-01-13T09:41:10-07:00
I'm encountering an issue trying to read a .jpg file and see whether it is interlaced. To test, I'm using an image that I know to be interlaced. Here is the code I'm using:
So this seems to be telling me it's not interlaced.
However, I decided to try to access the same image as an array ref, and this time, the result I got was that it is interlaced:
Just to be sure, I looked to see if there were any other images in the array, and there weren't any:
So I was able to work around this by using object->[0] instead of the object itself. What I am wondering is why this is? I spend a whole bunch of time trying to figure this out before thinking to use object->[0], so I am wondering if I missed something. I'm still mostly a novice using ImageMagick, so it could be just that I don't yet know how to do this properly.
I also verified with the command line that I can see that the image is interlaced, so I thought that just calling object->get('interlace') would give me the same information, but it doesn't:
Code: Select all
perl -MImage::Magick -e'my $i=Image::Magick->new; $i->Read("media/ProgressiveExample1-msuqBz.jpg"); warn $i->Get('interlace');'
None at -e line 1.
However, I decided to try to access the same image as an array ref, and this time, the result I got was that it is interlaced:
Code: Select all
perl -MImage::Magick -e'my $i=Image::Magick->new; $i->Read("media/ProgressiveExample1-msuqBz.jpg"); warn $i->[0]->Get('interlace');'
JPEG at -e line 1.
Code: Select all
perl -MImage::Magick -e'my $i=Image::Magick->new; $i->Read("media/ProgressiveExample1-msuqBz.jpg"); warn $i->[1]->Get('interlace');'
Can't call method "Get" on an undefined value at -e line 1.
I also verified with the command line that I can see that the image is interlaced, so I thought that just calling object->get('interlace') would give me the same information, but it doesn't:
Code: Select all
identify -verbose media/ProgressiveExample1-msuqBz.jpg | grep Interlace
Interlace: JPEG