possible bug or strange behavior -montage and PNG
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
possible bug or strange behavior -montage and PNG
IM 6.6.2.0 Q16 Mac OSX Tiger.
I am puzzled. If I do this, I get a strange result with png input to montage
convert -font arial -pointsize 25 label:'line 1' tmp1.png
convert -font arial -pointsize 12 label:'line2' tmp2.png
montage tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
But using gif input to montage, I get what I expect for the result:
convert -font arial -pointsize 25 label:'line 1' tmp1.gif
convert -font arial -pointsize 12 label:'line2' tmp2.gif
montage tmp1.gif tmp2.gif -tile 1x -geometry +0+5 test02.png
What am I misunderstanding here or is this a bug?
I am puzzled. If I do this, I get a strange result with png input to montage
convert -font arial -pointsize 25 label:'line 1' tmp1.png
convert -font arial -pointsize 12 label:'line2' tmp2.png
montage tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
But using gif input to montage, I get what I expect for the result:
convert -font arial -pointsize 25 label:'line 1' tmp1.gif
convert -font arial -pointsize 12 label:'line2' tmp2.gif
montage tmp1.gif tmp2.gif -tile 1x -geometry +0+5 test02.png
What am I misunderstanding here or is this a bug?
Re: possible bug or strange behavior -montage and PNG
The PNG image includes a label. Use -label "" in your montage command line to remove the label.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug or strange behavior -montage and PNG
Thanks. I see the label now in the verbose info for tmp1.png and I re-read the montage docs to see that it uses any label in the image. I never knew that using label:"something" would also put the label in the label field of the resulting image file. Learned something new today. Thanks again.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug or strange behavior -montage and PNG
testing -label "" does not seem to help
convert -font arial -pointsize 25 label:'line 1' -label "" tmp1.png
convert -font arial -pointsize 12 label:'line2' -label "" tmp2.png
montage tmp1.png tmp2.png -label "" -tile 1x -geometry +0+5 test01.png
I get the same bad result as in my first post above. Nor is the label removed from the verbose info in tmp1.png and tmp2.png
Am I doing this incorrectly?
convert -font arial -pointsize 25 label:'line 1' -label "" tmp1.png
convert -font arial -pointsize 12 label:'line2' -label "" tmp2.png
montage tmp1.png tmp2.png -label "" -tile 1x -geometry +0+5 test01.png
I get the same bad result as in my first post above. Nor is the label removed from the verbose info in tmp1.png and tmp2.png
Am I doing this incorrectly?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug or strange behavior -montage and PNG
Not all image formats support 'label' meta-data. and some support 'comment' meta-data.fmw42 wrote:Thanks. I see the label now in the verbose info for tmp1.png and I re-read the montage docs to see that it uses any label in the image. I never knew that using label:"something" would also put the label in the label field of the resulting image file. Learned something new today. Thanks again.
See Labeling Montage Images
http://www.imagemagick.org/Usage/montage/#label
However I did just come across a actual BUG.
In montage you can use -label or -set label to create a new label based in the input image. For example using this test image...
Code: Select all
convert rose: -set label 'rose' -set comment '(is a rose)' rose_with_metadata.png
Montage can show the label (the default)
Code: Select all
montage rose_with_metadata.png -geometry +1+1 rose_label.png
It can show the comment
Code: Select all
montage rose_with_metadata.png -set label '%c' -geometry +1+1 rose_comment.png
But if can not use a 'label escape' to show the label
Code: Select all
montage rose_with_metadata.png -set label '%l' -geometry +1+1 rose_label_escape.png
This means you can not label an image with both its input label and its comment.
Code: Select all
montage rose_with_metadata.png -set label '%l\n%c' -geometry +1+1 rose_label_comment.png
It seems like IM is destorying the 'old' label before applying the format escape sequences.
Cristy reports the above problem with -set label '%l' is now fixed in latest SVN, (for the next ImageMagick 6.6.2-2 release)
However in finding a work around for this bug I found that MIFF file format can save ANY meta-data you like to specify!
For example...
Code: Select all
convert rose: -set xyzzy 'Xyzzy' miff:- |
montage - -set label '%[xyzzy]' -geometry +1+1 rose_xyzzy.png
I actually use this technique in my new script kernel2image whcih I use to generate kernel images for IM examples
Morphology and Convolution pages
http://www.imagemagick.org/Usage/morphology/
(still under development).
Caution however is recommended with this as some of these are calculated escapes, and not extracted from image meta-data.
ASIDE: Set items without a "options:" prefix are known as "Image Properties" internally and in "identify -verbose", and are saved in MIFF. While items set with "options:" are "Image Attributes" and are generally used for expert or 'out-of-band' options used by various library options.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug or strange behavior -montage and PNG
label: sets the "label" image meta-data automatically.fmw42 wrote:testing -label "" does not seem to help
convert -font arial -pointsize 25 label:'line 1' -label "" tmp1.png
convert -font arial -pointsize 12 label:'line2' -label "" tmp2.png
montage tmp1.png tmp2.png -label "" -tile 1x -geometry +0+5 test01.png
I get the same bad result as in my first post above. Nor is the label removed from the verbose info in tmp1.png and tmp2.png
Am I doing this incorrectly?
To remove a label (before saving) use +set label or -set label ''
or while reading montage you can use +label or -label ''. Note that to montage these do NOT have the same meaning. NOTE that -set label will always replace the meta-data label from images in memory.
See IM Examples, Labeling Montage Images
http://www.imagemagick.org/Usage/montage/#label
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug or strange behavior -montage and PNG
OK. After reading further at http://www.imagemagick.org/Usage/montage/#label
Using -set label "" after the image is read or created works:
convert -font arial -pointsize 25 label:'line 1' -set label "" tmp1.png
convert -font arial -pointsize 12 label:'line2' -set label "" tmp2.png
montage tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
convert -font arial -pointsize 25 label:'line 1' tmp1.png
convert -font arial -pointsize 12 label:'line2' tmp2.png
montage tmp1.png tmp2.png -set label "" -tile 1x -geometry +0+5 test01.png
or using -label "" before creating or reading the images works.
convert -label "" -font arial -pointsize 25 label:'line 1' tmp1.png
convert -label "" -font arial -pointsize 12 label:'line2' tmp2.png
montage tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
convert -font arial -pointsize 25 label:'line 1' tmp1.png
convert -font arial -pointsize 12 label:'line2' tmp2.png
montage -label "" tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
Perhaps the docs on -label could be made a bit clearer with respect to -label "" and -set label "" and where they need to be used in the command line
This is all very strange to me why two different operations are needed to do the same thing.
Using -set label "" after the image is read or created works:
convert -font arial -pointsize 25 label:'line 1' -set label "" tmp1.png
convert -font arial -pointsize 12 label:'line2' -set label "" tmp2.png
montage tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
convert -font arial -pointsize 25 label:'line 1' tmp1.png
convert -font arial -pointsize 12 label:'line2' tmp2.png
montage tmp1.png tmp2.png -set label "" -tile 1x -geometry +0+5 test01.png
or using -label "" before creating or reading the images works.
convert -label "" -font arial -pointsize 25 label:'line 1' tmp1.png
convert -label "" -font arial -pointsize 12 label:'line2' tmp2.png
montage tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
convert -font arial -pointsize 25 label:'line 1' tmp1.png
convert -font arial -pointsize 12 label:'line2' tmp2.png
montage -label "" tmp1.png tmp2.png -tile 1x -geometry +0+5 test01.png
Perhaps the docs on -label could be made a bit clearer with respect to -label "" and -set label "" and where they need to be used in the command line
This is all very strange to me why two different operations are needed to do the same thing.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug or strange behavior -montage and PNG
See Basics, Setting/Changing Image Attributesfmw42 wrote:This is all very strange to me why two different operations are needed to do the same thing.
http://www.imagemagick.org/Usage/basics/#settings
-label sets a format that will be applied as an image is read in or created.
-set label applies a lable immediatally to image in memory.
The first is easier to set a different label to each image as it is read in without needing to use parenthesis all the time. The second better for images that are already in memory (often after some very heavy processing, or make a final setting before saving, or using image attributes that are coming from the current or other images.
For example what will the difference in results be for each of the following commands...
Think before you try!
Code: Select all
montage -label '%wx%h' rose: -rotate 20 -geometry +3+3 show:
montage rose: -rotate 20 -set label '%wx%h' -geometry +3+3 show:
Code: Select all
montage rose: -rotate 20 -set label '%[width]x%[height]' -geometry +3+3 show:
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug or strange behavior -montage and PNG
got the first two, but had to look up how %{width] was defined at http://www.imagemagick.org/script/escape.php
your notes on the montage page are fairly clear. i just had not read them in depth until this came up.
But I think a note on the label: page that points out that an internal label is also created in the image file that will affect montage and whatever other files that use the internal label would be beneficial.
your notes on the montage page are fairly clear. i just had not read them in depth until this came up.
But I think a note on the label: page that points out that an internal label is also created in the image file that will affect montage and whatever other files that use the internal label would be beneficial.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug or strange behavior -montage and PNG
This also seems to work compacted to one command line
montage -label "" \( -font arial -pointsize 25 label:'line 1' \) \
\( -font arial -pointsize 12 label:'line2' \) \
-tile 1x -geometry +0+5 test02.png
montage -label "" \( -font arial -pointsize 25 label:'line 1' \) \
\( -font arial -pointsize 12 label:'line2' \) \
-tile 1x -geometry +0+5 test02.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug or strange behavior -montage and PNG
I have added an 'expert note' into IM examples for both label and caption with this, including a reference to Basics, Image Attributes and Settings.fmw42 wrote:But I think a note on the label: page that points out that an internal label is also created in the image file that will affect montage and whatever other files that use the internal label would be beneficial.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug or strange behavior -montage and PNG
Parenthesis is not needed in the above. They do nothing as you don't process the image with any operator after it is created. You only set settings which unless you have '-regard-parenthesis' set will not be restricted by parenthesis.fmw42 wrote:This also seems to work compacted to one command line
Code: Select all
montage -label "" \( -font arial -pointsize 25 label:'line 1' \) \ \( -font arial -pointsize 12 label:'line2' \) \ -tile 1x -geometry +0+5 test02.png
I would perhaps reset the -font and -pointsize if any of the images actually does have label meta-data attached (not in this case), as these settings at the end of the user given processing is used by montage to generate montage labels and titles.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/