-debug annotate > No output

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
QooooQ

-debug annotate > No output

Post by QooooQ »

Version: ImageMagick 6.3.7 02/18/08 Q16 on Ubuntu
This (as an example):

Code: Select all

  convert xc: -font Candice -pointsize 24 \
          -debug annotate -annotate 0 'Test' null: 2>&1 |\
    grep Metrics: | fmt -w80
doesn't produce anything (no error, no metrics) (but I need the descent value)

In general I use a Arialbd.ttf file, so the font is available, and is working in other commands.

Also my code is working on a mac, running ImageMagick 6.4.8-9


Does the 6.3.7 Version have a bug, or wasn't the debug annotate feature implemented back then ?
Or could it be due to not fully resolved dependencies ? Or even something much simpler ?

I ask all that questions cause my boss doesn't wan't to upgrade to a newer version (yet), so he looks for solutions that do not include the build of a complete new version.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -debug annotate > No output

Post by fmw42 »

I believe that you need to specify and image size using -size WxH, otherwise I think you get a 1x1 pixel image. See http://www.imagemagick.org/Usage/annotating/
QooooQ

Re: -debug annotate > No output

Post by QooooQ »

Hmm, the size doesn't help

By the way.... when I enter this (without the grep stuff)

Code: Select all

convert -size 400x400 xc: -font Candice -pointsize 24  -debug annotate -annotate 0 'Test' null: 2>&1
I get this (ubuntu with IM 6.3.7)

Code: Select all

2009-03-27T01:08:12+01:00 0:01 0.070u 6.3.7 Annotate convert[24566]: annotate.c/unknown/1442/Annotate
  Font /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf; font-encoding none; text-encoding none; pointsize 24
2009-03-27T01:08:12+01:00 0:01 0.070u 6.3.7 Annotate convert[24566]: annotate.c/unknown/1442/Annotate
  Font /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf; font-encoding none; text-encoding none; pointsize 24
convert: unable to read font `Candice'.
On Mac (IM 6.4.8-9)

Code: Select all

2009-03-27T00:07:53+00:00 0:01 0.050u 6.4.8 Annotate convert[93848]: annotate.c/RenderFreetype/1444/Annotate
  Font /Library/Fonts/Arial Italic.ttf; font-encoding none; text-encoding none; pointsize 24
2009-03-27T00:07:53+00:00 0:01 0.050u 6.4.8 Annotate convert[93848]: annotate.c/GetTypeMetrics/1001/Annotate
  Metrics: text: Test; width: 45; height: 28; ascent: 22; descent: -6; max advance: 32; bounds: 1,0  16.9219,18; origin: 45,0; pixels per em: 24,24; underline position: -4.5625; underline thickness: 2.34375
2009-03-27T00:07:53+00:00 0:01 0.050u 6.4.8 Annotate convert[93848]: annotate.c/RenderFreetype/1444/Annotate
  Font /Library/Fonts/Arial Italic.ttf; font-encoding none; text-encoding none; pointsize 24
convert: unable to read font `Candice' @ annotate.c/RenderType/1075.
In the first output it says annotate.c/unknown/ so I also tried label: and caption: instead of annotate, cause I wasn't sure what is meant by annotate.c, but it says in all three cases annotate.c/unknown/.....

Is this relevant ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -debug annotate > No output

Post by fmw42 »

this works for me (Mac OSX Tiger IM 6.5.0-9beta):

convert -size 400x400 xc: -font Candice -pointsize 24 -debug Annotate -annotate 0 'Test' null: 2>&1

2009-03-26T17:45:51-07:00 0:01 0.330u 6.5.0 Annotate convert[1405]: annotate.c/RenderFreetype/1458/Annotate
Font /Library/Fonts/Candice.ttf; font-encoding none; text-encoding none; pointsize 24
2009-03-26T17:45:51-07:00 0:01 0.330u 6.5.0 Annotate convert[1405]: annotate.c/GetTypeMetrics/1001/Annotate
Metrics: text: Test; width: 46.4219; height: 29; ascent: 20; descent: -7; max advance: 30; bounds: -0.421875,-3 24,16; origin: 46,0; pixels per em: 24,24; underline position: -1.25; underline thickness: 0.78125
2009-03-26T17:45:51-07:00 0:01 0.340u 6.5.0 Annotate convert[1405]: annotate.c/RenderFreetype/1458/Annotate
Font /Library/Fonts/Candice.ttf; font-encoding none; text-encoding none; pointsize 24

as does this:

convert xc: -font Candice -pointsize 24 -debug Annotate -annotate 0 'Test' null: 2>&1

2009-03-26T17:46:51-07:00 0:02 0.310u 6.5.0 Annotate convert[1418]: annotate.c/RenderFreetype/1458/Annotate
Font /Library/Fonts/Candice.ttf; font-encoding none; text-encoding none; pointsize 24
2009-03-26T17:46:52-07:00 0:02 0.310u 6.5.0 Annotate convert[1418]: annotate.c/GetTypeMetrics/1001/Annotate
Metrics: text: Test; width: 46.4219; height: 29; ascent: 20; descent: -7; max advance: 30; bounds: -0.421875,-3 24,16; origin: 46,0; pixels per em: 24,24; underline position: -1.25; underline thickness: 0.78125
2009-03-26T17:46:52-07:00 0:02 0.310u 6.5.0 Annotate convert[1418]: annotate.c/RenderFreetype/1458/Annotate
Font /Library/Fonts/Candice.ttf; font-encoding none; text-encoding none; pointsize 24

Perhaps you don't have Candice font. If you do, then try giving the full path to Candice.ttf
QooooQ

Re: -debug annotate > No output

Post by QooooQ »

As I said, the font is not the problem.
I tried the second way in the http://www.imagemagick.org/Usage/text/#font_info example and it works.

Here's how I did it (in php)

Code: Select all

$command_2 = "convert -size 100x150 xc:lightblue -font '$font' -pointsize $size "
         ."-fill none -undercolor white  -annotate +20+100 'A' -trim  info:";
$output=shell_exec($command_2);

$tbb_start         		= strpos($output,"x",1)+1;
$tbb_length         	= strpos($output," ",$tbb_start)-$tbb_start;
$tob_start         		= strpos($output,"+",strpos($output,"+",$tbb_start)+1)+1;
$tob_length         	= strpos($output," ",$tob_start)-$tob_start;
$total_bounding_box 	= substr($output,$tbb_start,$tbb_length);
$top_of_box_2      		= substr($output,$tob_start,$tob_length);
$box_starts         	= 100 - $top_of_box_2;
$descent         		= $total_bounding_box - $box_starts - 1;
Case closed.
(Well I still like to know why it didn't work the first way, but maybe it really just wasn't implemented back then)
Last edited by QooooQ on 2009-03-29T18:12:03-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: -debug annotate > No output

Post by anthony »

The image size does not matter as you are wanting the report on font information, not the image itself.

However the use of -debug annotate was a later addition to IM.

Unfortunately I don't know WHEN it was added to IM, as it is NOT listed in the ChangeLog! But due to system crashes I am also unable to go back though the source code updates in the SVN repository to discover when it was added.

As such I can not documented the version of IM when the font metric reporting was added.

Obviously some time after IM v6.3.7 but before IM v6.4.8-9 That is a BIG gap!
Change log does show some annotate work was done around IM v6.4.8-7 (for text rotation and skewing, which was added then removed again) but nothing about debug output.


Addendum....
A search of the forums show Cristy added it in response to a user bug complaint about lack of access to font metric information, on 29 February 2008. Change logs equate that date with IM v6.3.9-2 as IM that first contained the font metric debug output.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
QooooQ

Re: -debug annotate > No output

Post by QooooQ »

Nice post ... :D

And so detailed... :D
very cool

Thank you very much

Only thing left now would be a small note of that fact in the example page for all the other people trying to use this font metrics retrieval technique :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: -debug annotate > No output

Post by anthony »

As soon as I had it I added it to IM examples. However it will not be on the official site for a day or two, until the change filters though. Only a few people have access to my test web server (my private workstation), where my change is immediately visible.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply