Impossible to add text into a TIF file

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
iceman17972

Impossible to add text into a TIF file

Post by iceman17972 »

HI,
I'm using this command to add a text in a tif file:

convert -font Arial -pointsize 72 -compress group4 -draw "text 100,100 'This is a text'" 116288.tif labeled.tif

The output tif file is created but NO NEW TEXT in it... :-((
Why?

The result of the identify command is:
116288.tif TIFF 6607x4670+0+0 DirectClass 1-bit 156.172kb 0,391u 0:01

Thanks in Advance.
Paolo
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Impossible to add text into a TIF file

Post by anthony »

try reading in the image before attempting to draw on it!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
iceman17972

Re: Impossible to add text into a TIF file

Post by iceman17972 »

Sorry... How cuould I do this? :shock:
how can I read the image?

Thanks again.
Bye
Paolo
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Impossible to add text into a TIF file

Post by anthony »

Code: Select all

convert 116288.tif -font Arial -pointsize 72  -annotate +100+100 'This is a text' -compress group4 labeled.tif
Read the image BEFORE drawing text onto it!!!

Read IM Exmaples BASICS
http://imagemagick.org/Usage/basics/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
iceman17972

Re: Impossible to add text into a TIF file

Post by iceman17972 »

Sorry.. but your code doesn't work.
The annotation isn't added to the tif file and the output tif is corrupted (the drawing into it is cut).

Thanks in advance.
Paolo
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Impossible to add text into a TIF file

Post by anthony »

I think we need a small example.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Impossible to add text into a TIF file

Post by RQuadling »

This is a few lines from my convert.log file which is a record of all the converts that a batch file I have has run.

CONVERT "Y:\CCC\received\2007\11\30\2007-11-30__07-16__Page-0001__9KFC9A.jpg" -resize 1728 -bordercolor black -fill black -border 0x100 -draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:16' font-size 140 text 1422,94 '0001' fill white font-size 110 stroke black text 550,76 '9 K F C 9 A'" -rotate 180 -draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:16' font-size 140 text 1422,94 '0001' fill white font-size 110 stroke black text 550,76 '9 K F C 9 A'" -rotate 180 -units PixelsPerInch -density 204x196 -quality 0 -type Optimize "Y:\CCC\received\2007\11\30\2007-11-30__07-16__Page-0001__9KFC9A.jpg"

CONVERT "Y:\CCC\received\2007\11\30\2007-11-30__07-18__Page-0002__IG2E3H.jpg" -resize 1728 -bordercolor black -fill black -border 0x100 -draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:18' font-size 140 text 1422,94 '0002' fill white font-size 110 stroke black text 550,76 'I G 2 E 3 H'" -rotate 180 -draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:18' font-size 140 text 1422,94 '0002' fill white font-size 110 stroke black text 550,76 'I G 2 E 3 H'" -rotate 180 -units PixelsPerInch -density 204x196 -quality 0 -type Optimize "Y:\CCC\received\2007\11\30\2007-11-30__07-18__Page-0002__IG2E3H.jpg"

CONVERT "Y:\CCC\received\2007\11\30\2007-11-30__07-19__Page-0003__RBPF4C.jpg" -resize 1728 -bordercolor black -fill black -border 0x100 -draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:19' font-size 140 text 1422,94 '0003' fill white font-size 110 stroke black text 550,76 'R B P F 4 C'" -rotate 180 -draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:19' font-size 140 text 1422,94 '0003' fill white font-size 110 stroke black text 550,76 'R B P F 4 C'" -rotate 180 -units PixelsPerInch -density 204x196 -quality 0 -type Optimize "Y:\CCC\received\2007\11\30\2007-11-30__07-19__Page-0003__RBPF4C.jpg"


This code has run well over 200,000 faxes with no problems.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Impossible to add text into a TIF file

Post by anthony »

Sorry, that I am not going to wade through. I said a small example, as in a small image with the simplified command for testing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Impossible to add text into a TIF file

Post by RQuadling »

anthony wrote:Sorry, that I am not going to wade through. I said a small example, as in a small image with the simplified command for testing.
Ha ha. Anthony, that was just an example from my system to show that you CAN quite easily add text to TIF files. I'm not the person who asked for help.

Ok, so it wasn't so simple. And getting all the settings to maintain a TIF file is quite hard as I didn't understand what the settings all meant myself.

Step by step breakdown of one of these beasts.

The command to execute

Code: Select all

CONVERT
The file to work open and work upon

Code: Select all

"Y:\CCC\received\2007\11\30\2007-11-30__07-16__Page-0001__9KFC9A.jpg"
Make the file 1728 pixels wide, rescaling as appropriate and maintain aspect ratio

Code: Select all

-resize 1728
Set the border colour to black

Code: Select all

-bordercolor black
Set the fill colour to black

Code: Select all

-fill black
Add a border of 100 pixel to the Y axis - don't add a border to the X axis.

Code: Select all

-border 0x100
Draw a header in the new border area - This draws a date and time in the top left of the new border, a page number in the top right and a special code in the middle.
It uses the Consolas font to help differentiate 1/I/l O/0.

Code: Select all

-draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:16' font-size 140 text 1422,94 '0001' fill white font-size 110 stroke black text 550,76 '9 K F C 9 A'"
Rotate the entire page.

Code: Select all

-rotate 180
Draw another "header", but this is now the "footer" due to the rotation.

Code: Select all

-draw "fill white stroke black stroke-width 1 rectangle 0,0 1727,99 fill black rectangle 0,0 339,99 rectangle 1420,0 1727,99 fill black font Consolas font-size 60 stroke white stroke-width 4 text 5,44 '2007/11/30' text 88,94 '07:16' font-size 140 text 1422,94 '0001' fill white font-size 110 stroke black text 550,76 '9 K F C 9 A'"
Rotate the page pack to where it should be.

Code: Select all

-rotate 180
Faxes need to have a specific density.

Code: Select all

-units PixelsPerInch

Code: Select all

-density 204x196
Absolutely no idea but was necessary.

Code: Select all

-quality 0
Again, no idea but had an effect on filesize.

Code: Select all

-type Optimize
Finally output the file, which in this case, is back to the original file.

Code: Select all

"Y:\CCC\received\2007\11\30\2007-11-30__07-16__Page-0001__9KFC9A.jpg"
Basically, this adds a border to the top and the bottom of a fax. The bottom border is rotated so that it is readable whichever way up the actual fax is read.

I've just done a quick check and this year alone, this code has worked on over 23,000 faxes (TIFF) and scans (JPG with a slightly different script).
Post Reply