Adding a text banner to a tiff 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
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Adding a text banner to a tiff file.

Post by RQuadling »

Hi.

We receive faxes via a fax card (4 lines - around 1000 pages a day).

I currently have a script which takes the fax (which may contain multiple pages), splits them into individual pages, gives them a unique name based upon the date and time the fax was received and the page number for the day (so we have file names like 2006-12-04__09-53_30__Page-0021__xxxxxx.tif, where xxxxxx is a magic code which is typed by the users to match the work they do to a fax page.

As part of the script, an email is generated to the job manager account which sends the fax to the next available operator.

The operator receives a fax via an email. The email contains a http link to the fax. They open the fax, maybe add annotations, enter the data on the fax into the accounts, save, etc. Finally they tag the fax as entered. This removes the fax from their email box and triggers the next page.

A fax of 50 pages may be entered by 50 different operators as the pages are not connected in any way. Each page is a job performed by a mechanic and they send their work in batches.


So. Thats the working scenario.


Now the problem.

SOMETIMES, the software responsible for passing the jobs out to the operators fails. Not my software, and I am NOT in a position to do anything about it. The authors are always "looking into it" and I'm REALLY fed up with it.

As a fix, I add another step to my script to actually print the fax. This means we have our digital copy available on the server and a hard copy for them to enter the data from, but no mechanism to join them together.

What I want to be able to do is to take a single page TIFF file, increase the length of the file and add a line of text which is basically the filename.

All of this is being done in a combination of .BAT, some PHP and a few Cygwin tools on Windows.

Any suggestions? Can I do the writing to a tiff file using ImageMagick?

Thank you.

Richard Quadling.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

ImageMagick will do what you want. See http://www.cit.gu.edu.au/~anthony/graphics/imagick6 for help determining the correct command.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Post by RQuadling »

The main problem that I have is that I don't know the length of the images.

I know that they will ALWAYS be 1728 pixels wide.

The length depends the length of the original page sent at the other end.

I've manage to create a banner as a separate file.

I intend to then append the two images into 1.

I'm sure I should be able to take an image, add 100 pixels to the top of the image. I just can't quite work it out.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Post by RQuadling »

This is the command I am using to create a banner

Code: Select all

CONVERT -size 1728x100 xc:white -draw "  fill black  stroke black  rectangle 0,0 339,99  rectangle 1419,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '2006/12/03'  text 88,94 '14:21'  font-size 140  text 1422,94 '0016'  fill white  font-size 110  stroke black  text 610,76 '3YBG2NC'"  3YBG2NCa.png
This creates a png and I can preview it using Windows Picture and Fax Viewer.

If I change the type to .tif, then I can't. I CAN open it in Microsoft Office Image and Document Manager, but this is not the application that the users are using. All the faxes we receive are currently accessible using WPFV.

I also have cygwin installed and the tiffinfo program reveals some interesting info.

The faxes I receive are compressed using CCITT Group 4 compression

Code: Select all

C:\>tiffinfo 03\2006-12-03__10-11__Page-0001__92CUP6.tif
TIFF Directory at offset 0x15424 (87076)
  Subfile Type: (0 = 0x0)
  Image Width: 1728 Image Length: 2282
  Resolution: 204, 196 pixels/inch
  Bits/Sample: 1
  Compression Scheme: CCITT Group 4
  Photometric Interpretation: min-is-white
  Samples/Pixel: 1
  Rows/Strip: 2282
  Planar Configuration: single image plane
Using convert -list Compression, I can see that Fax and Group4 compression mechanisms are available (they are different!).

So, I tried

Code: Select all

CONVERT -size 1728x100 xc:white -draw "  fill white  stroke black  stroke-width 1  rectangle 0,0 1727,99  fill black  rectangle 0,0 339,99  rectangle 1419,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '%1/%2/%3'  text 88,94 '%4:%5'  font-size 140  text 1422,94 '%7'  fill white  font-size 110  stroke black  text 610,76 '%8'"  %8-blank.tif
CONVERT -compress none -size 1728x100 xc:white -draw "  fill white  stroke black  stroke-width 1  rectangle 0,0 1727,99  fill black  rectangle 0,0 339,99  rectangle 1419,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '%1/%2/%3'  text 88,94 '%4:%5'  font-size 140  text 1422,94 '%7'  fill white  font-size 110  stroke black  text 610,76 '%8'"  %8-none.tif
CONVERT -compress Group4 -size 1728x100 xc:white -draw "  fill white  stroke black  stroke-width 1  rectangle 0,0 1727,99  fill black  rectangle 0,0 339,99  rectangle 1419,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '%1/%2/%3'  text 88,94 '%4:%5'  font-size 140  text 1422,94 '%7'  fill white  font-size 110  stroke black  text 610,76 '%8'"  %8-group4.tif
CONVERT -compress Fax -size 1728x100 xc:white -draw "  fill white  stroke black  stroke-width 1  rectangle 0,0 1727,99  fill black  rectangle 0,0 339,99  rectangle 1419,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '%1/%2/%3'  text 88,94 '%4:%5'  font-size 140  text 1422,94 '%7'  fill white  font-size 110  stroke black  text 610,76 '%8'"  %8-fax.tif
The resultant files are

Code: Select all

06/12/2006  10:15           346,321 92CUP6-blank.tif
06/12/2006  10:15           136,989 92CUP6-fax.tif
06/12/2006  10:15           136,991 92CUP6-group4.tif
06/12/2006  10:15           346,319 92CUP6-none.tif
Tiffinfo reveals

Code: Select all

C:\>for %t in (*.tif) do tiffinfo %t

C:\>tiffinfo 92CUP6-blank.tif
TIFF Directory at offset 0x54608 (345608)
  Image Width: 1728 Image Length: 100
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 2
  Rows/Strip: 2
  Planar Configuration: single image plane
  DocumentName: 92CUP6-blank.tif
  Software: ImageMagick 6.3.1 12/02/06 Q8 http://www.imagemagick.org

C:\>tiffinfo 92CUP6-fax.tif
TIFF Directory at offset 0x21456 (136278)
  Image Width: 1728 Image Length: 100
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: PackBits
  Photometric Interpretation: min-is-black
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 2
  Rows/Strip: 2
  Planar Configuration: single image plane
  DocumentName: 92CUP6-fax.tif
  Software: ImageMagick 6.3.1 12/02/06 Q8 http://www.imagemagick.org

C:\>tiffinfo 92CUP6-group4.tif
TIFF Directory at offset 0x21456 (136278)
  Image Width: 1728 Image Length: 100
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: PackBits
  Photometric Interpretation: min-is-black
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 2
  Rows/Strip: 2
  Planar Configuration: single image plane
  DocumentName: 92CUP6-group4.tif
  Software: ImageMagick 6.3.1 12/02/06 Q8 http://www.imagemagick.org

C:\>tiffinfo 92CUP6-none.tif
TIFF Directory at offset 0x54608 (345608)
  Image Width: 1728 Image Length: 100
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 2
  Rows/Strip: 2
  Planar Configuration: single image plane
  DocumentName: 92CUP6-none.tif
  Software: ImageMagick 6.3.1 12/02/06 Q8 http://www.imagemagick.org
So, I think the production of tif files within convert is not quite right.

Any assistance would be REALLY useful!

Regards,

Richard Quadling.
sashu100

Re: Adding a text banner to a tiff file.

Post by sashu100 »

Thanks for the info..... :D even i had the same problem....... now it got fixed......

data entry india
Post Reply