An easy way to do this is to transfer ImageMagick work through the PerlMagick CPAN module. For this purpose, methods Identifyand have been developed Ping.
use strict;
use Image::Magick;
my $im = Image::Magick->new();
my ($width, $height, $size, $format) = $im->Ping('/path/to/my/image.jpg');
$format ( : "JPEG" ) undef ( , ..).
:... : , , , Ping , , ImageMagick ( ).