Page 1 of 1

Fast identify for embedded color profile

Posted: 2013-10-18T12:10:39-07:00
by nator
I would like to propose adding an option to identify -format "[format string]" to enable rapid detection of embedded icc/icm profiles.

Both currently available methods are too slow for my needs: identify -verbose [filename] | grep -A1 'Profile-ic' and convert [filename] test.icc.

The problem is I don't need the full details of verbose, and I certainly don't need to convert the whole file to test for an icc. I just need to know (quickly!) if it exists so I don't double-apply profiles.

Thanks!

Code: Select all

--- magick/property.c.bak	2013-10-18 13:51:10.000000000 -0500
+++ magick/property.c	2013-10-18 13:51:16.000000000 -0500
@@ -2372,6 +2372,22 @@
         image->page.height);
       break;
     }
+    case 'I': /* presence of icc profile */
+    {
+      ResetImageProfileIterator(image);
+      const char *name=GetNextImageProfile(image);
+      while (name != (char *) NULL)
+      {
+        if ((LocaleCompare(name,"icc") == 0) ||
+                  (LocaleCompare(name,"icm") == 0))
+        {
+          (void) FormatLocaleString(value,MaxTextExtent,"%s",name);
+          break;
+        }
+        name = GetNextImageProfile(image);
+      }
+      break;
+    }
     case 'M': /* Magick filename - filename given incl. coder & read mods */
     {
       string=image->magick_filename;

Re: Fast identify for embedded color profile

Posted: 2013-10-18T13:28:09-07:00
by dlemstra
I personally prefer Fred's property names: viewtopic.php?f=1&t=24286#p104075.

identify -format "%[profile:icc]\n" someimage (similarly for icm)
and
identify -format "%[profiles]\n" someimage

Re: Fast identify for embedded color profile

Posted: 2013-10-18T13:29:18-07:00
by Bonzo
From memory adding -ping speeds things like this up?

Re: Fast identify for embedded color profile

Posted: 2013-10-18T13:33:18-07:00
by nator
Bonzo wrote:From memory adding -ping speeds things like this up?
Winner!!! Holy smokes, that's fast. I would still prefer eventually to incorporate this into my existing identify call (and prefer Fred's syntax as well), but in the meantime you have saved the day:

Code: Select all

convert -ping [filename] /tmp/test.icc
is lightning fast. Thank you!

Re: Fast identify for embedded color profile

Posted: 2013-10-19T08:19:19-07:00
by dlemstra
Thanks for your idea. It has been implemented and you can use it in the next release of ImageMagick:

Code: Select all

C:\Test>identify -format "%[profile:icc]" test.tif
Coated FOGRA27 (ISO 12647-2:2004)

C:\Test>identify -format "%[profiles]" test.tif
8bim,icc,xmp

Re: Fast identify for embedded color profile

Posted: 2013-10-19T08:21:38-07:00
by nator
Brilliant! Thanks so much for the quick turnaround. Big IM fan now even bigger. :)