Page 1 of 1

contribution: extend identify format with orientation info

Posted: 2012-04-01T06:05:30-07:00
by pandaemonium
For a project I'm currently working on I need quick and easy access to an image's orientation. Up to now it has always been enough to get the info from exif:orientation (e.g. identify -format %[exif:orientation]). Unfortunately I've recently encountered some TIFFs that had a non-standard orientation (and thus were rotated by convert -auto-orient) but didn't expose this information via Exif-Tags. I'm able to retrieve the orientation information via identify -verbose, but stuff like the calculation of Channel statistics can be very time consuming for (very) large images.

My proposal for solving this issue is extending the ImageMagick Escapes and adding a %[orientation] property.

Code: Select all

--- ImageMagick-6.7.6-1/magick/property.c       2012-03-17 17:25:15.000000000 +0100
+++ ImageMagick-6.7.6-1_mod/magick/property.c   2012-04-01 14:46:53.122072396 +0200
@@ -2352,6 +2352,12 @@
             "true",MaxTextExtent);
           break;
         }
+      if (LocaleNCompare("orientation",property,11) == 0)
+        {
+          (void) FormatLocaleString(value,MaxTextExtent,"%s",
+          CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t) image->orientation));
+          break;
+        }
       if (LocaleNCompare("output",property,6) == 0)
         {
           (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
I hope this simple contribution gets accepted and helps other that are in need of such a feature.

Re: contribution: extend identify format with orientation in

Posted: 2012-04-01T07:05:37-07:00
by magick
We applied your patch to the ImageMagick subversion trunk available by sometime tomorrow. Thanks.

Re: contribution: extend identify format with orientation in

Posted: 2012-04-01T11:34:07-07:00
by pandaemonium
Thanks alot. I just noticed that the new ImageMagick escape should also be documented so others know about its presence.

Code: Select all

--- ImageMagick-6.7.6-1/www/escape.html 2012-03-17 23:02:33.000000000 +0100
+++ ImageMagick-6.7.6-1_mod/www/escape.html     2012-04-01 20:31:16.639488354 +0200
@@ -321,6 +321,7 @@
    %[min]
    %[name]                                                                                                   
    %[opaque]                                                                                                 
+   %[orientation]                                                                                            
    %[page]                                                                                                   
    %[scene]                original scene number of image in input file                                      
    %[scenes]               original number of scenes in input file  

Re: contribution: extend identify format with orientation in

Posted: 2012-04-01T12:19:00-07:00
by magick
We documented the change, it won't be exported thought to tomorrow.