Page 1 of 1

possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-16T13:52:58-07:00
by fmw42
# create label
convert rose: -set label "testing" rose.png

# extract label

This works:
identify -format "%[label]\n" rose.png
testing

This works:
convert rose.png -format "%l\n" info:
testing

These return nothing (lower case L not I):
identify -format "%l" rose.png

identify -format "%l\n" rose.png

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-16T14:57:33-07:00
by snibgo
Behaviour confirmed on Windows, IM v6.8.6-9 and many older versions.

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-16T17:42:06-07:00
by magick
Try
  • identify +ping -format "%l" rose.png

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-16T18:02:14-07:00
by snibgo
Yup, "+ping" does the trick (in Windows).

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-16T18:15:33-07:00
by fmw42
magick wrote:Try
  • identify +ping -format "%l" rose.png

Works for me also on IM 6.8.6.9 Q16 Mac OSX.

But does this mean that +ping is the solution for this or you just need it to verify what is going on?

Its use does not seem consistent. Since

identify -format "%w\n" rose.png

works fine without +ping

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-17T04:36:54-07:00
by magick
By default we "ping" an image. That is, read certain meta information about the image and bail before we read the image pixels. This makes reading images very fast and consumes few resources. Unfortunately the label information is not available when pinging PNG images, thus the +ping requirement. This is specific to PNG which locates the label after the image pixels (DAT section).

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-17T10:00:24-07:00
by fmw42
Thanks for the explanation.

But why does

convert rose.png -format "%l" info:

work. Does it not do ping by default? Is that how it is different from identify?

Re: possible bug "%l" (label) IM 6.8.6.9 Q16 Mac OSX

Posted: 2013-09-18T22:00:27-07:00
by anthony
convert does not 'ping' images it always reads in the image in total into memory.
As such labels and other meta data (beyond basic image width,height, depth, colorspace) is available.

NOTE that using any more complex format escape, (eg %[...]) or verbose will automatically disable this default minimal 'ping' image read!

I have updated the identify section in IM Examples basics..
Identify, to Ping or not to Ping
http://www.imagemagick.org/Usage/basics/#identify_ping

Should appear in a hour or two.

Question is does using '-ping' ensure that images are not read in total.

For example this turns off the minimal 'ping' read I specifically requested to be performed!

Code: Select all

identify -ping -format '"%[l]"\n' rose.png
In this case I actually do set the label, meaning the image was full read in, even though I requested it not to have been!

Why is this important? because we may only being doing some simple mathematics that does not need all the information.

Code: Select all

identify -ping -format '"%[fx:w*2]x%[fx:h*2]"\n' rose.png
In this case a 'ping' is actually really wanted as I don't need image data!
But identify still reads in the whole image!

This I consider a real BUG.