Steven email: sjh@svana.org
web: https://svana.org/sjh Other online diaries:
Aaron Broughton, Links:
Linux Weekly News, Canberra Weather: forecast, radar.
Categories:
|
Mon, 25 Jul 2005
Monday night inner tube blogging. - 22:19
Faster exif - 21:57
I installed the library, had a look around for a photo I was unlikely to have modified at all (and thus would still have all its tags) and found my 2004 Triple Tri photos. Using the following snippet of perl code.
time perl -e 'use Image::EXIF; use Data::Dumper; my $exif = new Image::EXIF \ ("img_0869.jpg"); my $all_info = $exif->get_all_info(); print $exif->error ? \ $exif->errstr : Dumper($all_info);' I get the following output.
$VAR1 = { 'unknown' => { 'Min Focal Length' => 'num 24, val 0x00AD', 'Focal Units/mm' => 'num 25, val 0x0020', 'Manufacturer Notes' => '942', 'Canon Tag1 Unknown' => 'num 06, val 0x0000', 'Interoperability IFD Pointer' => '1540', 'Comment' => '614', 'Canon Tag4 Unknown' => 'num 01, val 0x0000', 'Canon Unknown' => '1448', 'Flash Activity' => 'num 28, val 0x0000', 'Max Focal Length' => 'num 23, val 0x0207', 'Autofocus Point' => 'num 14, val 0x0000', 'Canon Tag4 Offset' => '1224', 'Supported FlashPix Version' => '808464688', 'Flash Details' => 'num 29, val 0x0000', 'Unknown' => '1600', 'Canon Tag1 Offset' => '1116' }, 'other' => { 'Vertical Resolution' => '180 dpi', 'Canon Tag1 Length' => '92', 'White Balance' => 'Auto', 'Exif Version' => '2.20', 'Resolution Unit' => 'i', 'Focal Plane Res Unit' => 'i', 'Image Digitized' => '2004:11:20 17:58:35', 'Canon Tag4 Length' => '68', 'Shutter Speed' => '1/807 sec', 'Focal Plane Vert Resolution' => '7741 dpi', 'Image Generated' => '2004:11:20 17:58:35', 'Bytes of JPEG Data' => '5141', 'Metering Mode' => 'Pattern', 'Chrominance Comp Positioning' => 'Centered', 'Compression Scheme' => 'JPEG Compression (Thumbnail)', 'Horizontal Resolution' => '180 dpi', 'Image Type' => 'IMG:PowerShot A60 JPEG', 'Digital Zoom Ratio' => '1', 'Offset to JPEG SOI' => '2036', 'Image Compression Mode' => '3', 'Digital Zoom' => 'None', 'Sequence Number' => '0', 'Focal Plane Horiz Resolution' => '7766 dpi', 'Flash Bias' => '0 EV', 'Base Zoom Resolution' => '1600', 'Meaning of Each Comp' => 'Unknown', 'Self-Timer Length' => '0 sec', 'Zoomed Resolution' => '1600', 'File Source' => 'Digital Still Camera', 'Owner Name' => '', 'Exif IFD Pointer' => '196' }, 'camera' => { 'Firmware Version' => 'Firmware Version 1.00', 'Camera Model' => 'Canon PowerShot A60', 'Equipment Make' => 'Canon', 'Lens Size' => '5.41 - 16.22 mm', 'Maximum Lens Aperture' => 'f/2.8', 'Sensing Method' => 'One-Chip Color Area' }, 'image' => { 'Vertical Resolution' => '180 dpi', 'White Balance' => 'Auto', 'Contrast' => 'Normal', 'Rendering' => 'Normal', 'Compression Setting' => 'Fine', 'Image Height' => '1200', 'Image Orientation' => 'Top, Left-Hand', 'Color Space Information' => 'sRGB', 'Macro Mode' => 'Normal', 'Focus Mode' => 'Single', 'Exposure Mode' => 'Easy Shooting', 'Exposure Time' => '1/800 sec', 'F-Number' => 'f/2.8', 'ISO Speed Rating' => 'Auto', 'Image Width' => '1600', 'Scene Capture Type' => 'Standard', 'Image Size' => 'Large', 'Drive Mode' => 'Single', 'Lens Aperture' => 'f/2.8', 'Sharpness' => 'Normal', 'Metering Mode' => 'Evaluative', 'Horizontal Resolution' => '180 dpi', 'Shooting Mode' => 'Full Auto', 'Image Number' => '108-0869', 'Saturation' => 'Normal', 'Flash' => 'No Flash, Auto', 'Image Created' => '2004:11:20 17:58:35', 'Focus Type' => 'Auto', 'Flash Mode' => 'Red-Eye Reduction (Auto)', 'Focal Length' => '5.41 mm', 'Exposure Bias' => '0 EV', 'Subject Distance' => '2.720 m' } }; real 0m0.068s user 0m0.034s sys 0m0.002s All this, including the time to load the libraries (Data::Dumper and Image::EXIF), the perl interpreter, the image file from disk. Executing on my 1.4 GHz laptop. Admittedly that was the second time I ran the code snippet, though I used a different image filename, so the libraries and interpreter were likely already hot in memory, it may blow out to all of 0.1 of a second if it has to do all that. Use native perl and available libraries to make things fast, it makes a lot of sense. It seems I often think of the perl bridge building quote in this sort of situation. Of course it kind of sucks if you are trying to write a book about using ImageMagick and find you have to use other tools because it is not as fast as you want or something. I notice Brad (the guy who started livejournal) often gets heavily into making perl go fast, worth reading sometimes just to make you think about what he is doing. |