contribution: extend identify format with orientation info

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
pandaemonium
Posts: 2
Joined: 2012-04-01T05:44:17-07:00
Authentication code: 8675308

contribution: extend identify format with orientation info

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: contribution: extend identify format with orientation in

Post by magick »

We applied your patch to the ImageMagick subversion trunk available by sometime tomorrow. Thanks.
pandaemonium
Posts: 2
Joined: 2012-04-01T05:44:17-07:00
Authentication code: 8675308

Re: contribution: extend identify format with orientation in

Post 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  
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: contribution: extend identify format with orientation in

Post by magick »

We documented the change, it won't be exported thought to tomorrow.
Post Reply