Page 1 of 1
pointsize reporting with best fit use of label:
Posted: 2010-06-17T11:27:20-07:00
by fmw42
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.
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T15:26:08-07:00
by snibgo
Good idea. Meanwhile, "-debug all" seems to list all the pointsizes tried.
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T16:08:30-07:00
by fmw42
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.
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T16:44:36-07:00
by snibgo
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.)
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T16:57:42-07:00
by fmw42
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
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T17:03:42-07:00
by magick
In the next release of ImageMagick, look for label:pointsize as a property.
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T17:10:58-07:00
by fmw42
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:
Posted: 2010-06-17T18:20:14-07:00
by magick
The patch will be available in one hour @ magick.imagemagick.org:pub/ImageMagick/beta.
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T21:20:55-07:00
by fmw42
magick wrote:The patch will be available in one hour @ magick.imagemagick.org:pub/ImageMagick/beta.
Perhaps I am premature in testing or do not understand how to extract the pointsize.
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
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-17T22:00:50-07:00
by anthony
fmw42 wrote:magick wrote:In the next release of ImageMagick, look for label:pointsize as a property.
Thanks. I am not sure how that will work.
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.
For example
outputs...
...
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
...
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'.
until then try...
Code: Select all
convert label:t -format '%[date:create]' info:
or
Code: Select all
convert label:t -print '%[date:create]\n' null:
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-18T09:31:31-07:00
by fmw42
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.
Re: pointsize reporting with best fit use of label:
Posted: 2010-06-18T19:29:49-07:00
by anthony
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.