Page 1 of 1

Fast way to detect embedded profile

Posted: 2013-10-18T11:52: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.

Thoughts? Am I missing a faster way to do this? The sips program on OS X is in the speed range I'm after, but since I need to run identify -format anyway I'd prefer to consolidate the call.

Thanks!

Re: Fast way to detect embedded profile

Posted: 2013-10-18T12:04:56-07:00
by fmw42
I would suggest you repost this on the Developers forum

Re: Fast way to detect embedded profile

Posted: 2013-10-18T12:07:13-07:00
by nator
Something like this meets my needs perfectly, but I'm dealing with situations where I can't build from source. Thanks for reviewing and incorporating!

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 way to detect embedded profile

Posted: 2013-10-18T12:08:33-07:00
by nator
fmw42 wrote:I would suggest you repost this on the Developers forum
I must be blind. Will do. Still, hoping for users to chime in support of this feature...

Re: Fast way to detect embedded profile

Posted: 2013-10-18T12:13:40-07:00
by fmw42
It seems like a reasonable thing. I do not know how hard it would be. Perhaps a string format something like

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

or

identify -format "%[profile-icc]\n" someimage


which would list the name (Description from the verbose info) of the icc profile


or

identify -format "%[profiles]\n" someimage

which would list all types of profiles that exist for the image.

Re: Fast way to detect embedded profile

Posted: 2013-10-18T12:24:27-07:00
by snibgo
I don't think there is a faster way, and this seems a useful enhancement.

However, in my tests I have noticed that "-profile sRGB.icc" takes no time if the input has no profile or already has sRGB embedded. It takes time only if it has a different profile embedded. (About 2 seconds for a 5000x7500 image on my oldish laptop.)