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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Behaviour confirmed on Windows, IM v6.8.6-9 and many older versions.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick »

Try
  • identify +ping -format "%l" rose.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Yup, "+ping" does the trick (in Windows).
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

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

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

Post 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).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply