pointsize reporting with best fit use of label:
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
pointsize reporting with best fit use of label:
I was wondering if it would be possible to report the pointsize created when using label: with a specified size only. For example:
convert -size 160x -background lightblue -fill white -verbose label:"TESTING" null:
reports
label:TESTING=>TESTING LABEL 160x41 160x41+0+0 16-bit DirectClass 0.190u 0:00.220
Would it be possible to include the resulting pointsize of the text that was drawn?
This would be very beneficial when trying to get the image size and pointsize for subsequent use with -annotate.
convert -size 160x -background lightblue -fill white -verbose label:"TESTING" null:
reports
label:TESTING=>TESTING LABEL 160x41 160x41+0+0 16-bit DirectClass 0.190u 0:00.220
Would it be possible to include the resulting pointsize of the text that was drawn?
This would be very beneficial when trying to get the image size and pointsize for subsequent use with -annotate.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: pointsize reporting with best fit use of label:
Good idea. Meanwhile, "-debug all" seems to list all the pointsizes tried.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: pointsize reporting with best fit use of label:
snibgo wrote:Good idea. Meanwhile, "-debug all" seems to list all the pointsizes tried.
Good catch Alan! Now I just need to filter all the attempts to get the final pointsize and dimensions. That might do in the meantime.
Fred
PS. Unfortunately, I am having trouble using SED or GREP to extract the pointsize only from the debug text. Not sure if it is me or the way the text is output. It seems to go to the terminal and cannot be piped to SED or GREP.
PS2. using -debug annotate (even with label:) seems to give similar pointsize information, but not everything else. However, I still cannot filter that to get just the last pointsize.
Last edited by fmw42 on 2010-06-17T16:48:54-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: pointsize reporting with best fit use of label:
On Windows, it goes to stderr, so
convert -size 160x -background lightblue -fill white -verbose -debug all label:"TESTING" null: 2>x.txt
and then grep and tail for the final pointsize. (But I haven't really played with this.)
convert -size 160x -background lightblue -fill white -verbose -debug all label:"TESTING" null: 2>x.txt
and then grep and tail for the final pointsize. (But I haven't really played with this.)
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: pointsize reporting with best fit use of label:
I had tried 2>&1 with no success. But your method does work.
convert -size 160x -background lightblue -fill white -debug annotate label:"TESTING" null: 2> text_label.txt
cat text_label.txt | sed -n 's/^.*[ ]*pointsize[ ]*\([0-9]*\)$/\1/p' | tail -n 1
However, it would be nice to avoid writing to a file.
Thanks Alan.
Fred
convert -size 160x -background lightblue -fill white -debug annotate label:"TESTING" null: 2> text_label.txt
cat text_label.txt | sed -n 's/^.*[ ]*pointsize[ ]*\([0-9]*\)$/\1/p' | tail -n 1
However, it would be nice to avoid writing to a file.
Thanks Alan.
Fred
Last edited by fmw42 on 2010-06-17T17:20:32-07:00, edited 2 times in total.
Re: pointsize reporting with best fit use of label:
In the next release of ImageMagick, look for label:pointsize as a property.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: pointsize reporting with best fit use of label:
magick wrote:In the next release of ImageMagick, look for label:pointsize as a property.
Thanks. I am not sure how that will work. Do you mean that it will be reported with -verbose as in my command earlier? If so, that will be terrific, because I want to be able to extract the width, height and pointsize when using label: from once instance and then I can filter the text returned to get each of these properties. That will help a lot when using label to get the width, height and pointsize to feed then to -annotate to do the more fancier text creation.
Let me know when in a Beta and I will test this.
Fred
Re: pointsize reporting with best fit use of label:
The patch will be available in one hour @ magick.imagemagick.org:pub/ImageMagick/beta.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: pointsize reporting with best fit use of label:
Perhaps I am premature in testing or do not understand how to extract the pointsize.magick wrote:The patch will be available in one hour @ magick.imagemagick.org:pub/ImageMagick/beta.
I just downloaded and installed 6.6.2-7 Beta and tried
convert -size 160x -background lightblue -fill white -verbose label:"TESTING" null:
label:TESTING=>TESTING LABEL 160x41 160x41+0+0 16-bit DirectClass 0.190u 0:00.200
label:TESTING=> LABEL 160x41 160x41+0+0 16-bit DirectClass 0.010u 0:00.000
But don't see the pointsize here. Am I doing something wrong or am I premature in testing? It is not urgent, if it is not ready yet
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: pointsize reporting with best fit use of label:
It means it will be set as an image properity (-set) or artifact (-define). probably the former. that in turn is accessible from verbose info: (identify) output, or -format percent escapes. Of course not all file formats will save the information, though it will be present in-memory or in MIFF.fmw42 wrote:Thanks. I am not sure how that will work.magick wrote:In the next release of ImageMagick, look for label:pointsize as a property.
For example
Code: Select all
convert label:t -verbose info:
whcih shows that 'label' contains the string that was used to generate the label! (something you recently came accross and commented on). When Cristy (magick) addes his code. then there will also be a label:pointsize 12 in the above. Which means you can access it using. a -format %[label:pointsize], just as you can with any other 'Property'....
Properties:
date:create: 2010-06-18T14:53:16+10:00
date:modify: 2010-06-18T14:53:16+10:00
label: t
signature: dfccf3ecae95aa07a323b231fd3ff9eae965249f4b9e66da83d274d6746e6e58
Artifacts:
verbose: true
...
until then try...
Code: Select all
convert label:t -format '%[date:create]' info:
Code: Select all
convert label:t -print '%[date:create]\n' null:
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: pointsize reporting with best fit use of label:
Thanks I see it now by doing:
convert \( -size 160x -background lightblue -fill white label:"TESTING" \) \
-verbose info:
Properties:
date:create: 2010-06-18T09:30:21-07:00
date:modify: 2010-06-18T09:30:21-07:00
label: TESTING
label:pointsize: 35
signature: 3c5ccc42fa207dac992b84878074c919a9d3c9eaebc39d3d101001407fbef0be
And this gets the width, height and pointsize
convert \( -size 160x -background lightblue -fill white label:"TESTING" \) \
-format "%wx%hx%[label:pointsize]" info:
160x41x35
Anthony, thanks for the explanation.
Thanks Magick for the implementation.
This will work great.
convert \( -size 160x -background lightblue -fill white label:"TESTING" \) \
-verbose info:
Properties:
date:create: 2010-06-18T09:30:21-07:00
date:modify: 2010-06-18T09:30:21-07:00
label: TESTING
label:pointsize: 35
signature: 3c5ccc42fa207dac992b84878074c919a9d3c9eaebc39d3d101001407fbef0be
And this gets the width, height and pointsize
convert \( -size 160x -background lightblue -fill white label:"TESTING" \) \
-format "%wx%hx%[label:pointsize]" info:
160x41x35
Anthony, thanks for the explanation.
Thanks Magick for the implementation.
This will work great.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: pointsize reporting with best fit use of label:
I am hoping to have these properties report other information too. For example it could report the number of primitive iterations morphology last performed. Or in a connected object labelling operation I could have IM report the number of connected objects that it found and coloured.
Note -set also sets these labels. For example -set filename:tile_offset '%O' +repage would remove the virtual pixel offset, but still keep a copy of it for later use.
You can use +set to remove property.
-set option:... however will defines a 'artefact' (such as verbose does in the above example) -define also only sets artefacts. Artefacts are meant only to be used by image processing operators such as coders and expert options. For exampe -set option:compose:args ... actually sets a -define compose:args=...
I only learned this facite of Im operations myself recently, so only have rough notes about it in "Basics, Settings" at this time.
Note -set also sets these labels. For example -set filename:tile_offset '%O' +repage would remove the virtual pixel offset, but still keep a copy of it for later use.
You can use +set to remove property.
-set option:... however will defines a 'artefact' (such as verbose does in the above example) -define also only sets artefacts. Artefacts are meant only to be used by image processing operators such as coders and expert options. For exampe -set option:compose:args ... actually sets a -define compose:args=...
I only learned this facite of Im operations myself recently, so only have rough notes about it in "Basics, Settings" at this time.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/