contribution: extend identify format with orientation info
Posted: 2012-04-01T06:05:30-07:00
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.
I hope this simple contribution gets accepted and helps other that are in need of such a feature.
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);