Problems using "-draw" on 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:

Problems using "-draw" on a TIFF file.

Post by RQuadling »

I'm SLOWLY getting to grips with ImageMagick.

Version: ImageMagick 6.3.1 12/09/06 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC

On Windows XP.

I need to add a banner to a fax file.

An original fax is available at http://rquadling.php1h.com/92CUP6.tif.

I have also included a BATCH file with comments about what I am trying to do to the fax http://rquadling.php1h.com/AddBanner.bat. The file contains

Code: Select all

@ECHO OFF
CLS
ECHO Create new image

REM Draw boxes with appropriate text in them.
SET DRW=-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 '2006/12/14'  text 88,94 '09:44'  font-size 140  text 1422,94 'Page 1234'  fill white  font-size 110  stroke black  text 610,76 '92CUP6'"

REM Try to draw a simple rectangle.
SET DRW=-draw "  rectangle 10,10 20,20"
REM Try to draw a coloured rectangle.
SET DRW=-draw " fill white  stroke white rectangle 10,10 20,20"

REM Try to draw some text.
SET DRW=-draw "text 10,10 'RAQ'"

REM Draw nothing.
SET DRW=

REM Take original image.
REM Add a border to the top and the bottom.
REM Add the text to the top of the image.
REM Rotate 180 degrees.
REM Add the text to the top (was the bottom) of the image.
REM Rotate 180 degrees to put the image the same way up.
REM Save it with a new name as a CITT4 fax.
CONVERT 92CUP6.tif -monochrome -units PixelsPerInch -density 204x196 -compress group4 -bordercolor black -fill black -border 0x100 %DRW% -rotate 180 %DRW% -rotate 180 92CUP6-new.tif
ECHO.
ECHO Info about new image
TIFFINFO 92CUP6-new.tif
ECHO.
ECHO Info about original image
TIFFINFO 92CUP6.tif

REM Show the image sizes - should be neglible difference.
DIR *.tif

REM Launch the default viewer (In my case the Windows Picture and Fax Viewer)
REM Must work as this is used by the users to add annotations.
start 92CUP6-new.tif
, but this form wraps the lines so it is harder to read.

I have managed to increase the size of the image by using

Code: Select all

-bordercolor black -fill black -border 0x100
I can save this as a valid Group4 tiff using

Code: Select all

-type bilevel -units PixelsPerInch -density 204x196 -compress group4
.

My problem is that drawing anything breaks the image completely.

I want to draw white text on a black background for the date and time in the top left (and the rotated bottom right) corners and the page number in in the top right (and the rotated bottom left) corners with the filename (not the extension) in the top centre (and the rotated bottom centre).

I am really stuck. I am sure I am nearly there.

Using -draw or -annotate both screw up the file.

The tiffinfo program used is part of Cygwin. I also have Paint Shop Pro and that cannot open the broken new file with. If only the border command is used, then I can open it in PSP and the Windows Preview work fine!

Please help!!!

Richard Quadling.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

Add +matte before the output filename.

Pete
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Post by RQuadling »

Hallelujah.

Thank you! Thank you! Thank you!

You have helped me a LOT!!!!

I can now release this to the users and they can marvel at my genius!

As I often say, "I'm standing on the shoulders of some very clever giants!".

Thank you!!!!

Oh.

T H A N K Y O U ! ! ! :D
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

:D Glad I could help :D
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

You do not need to set -fill for the -border operator, and there are lots of other ways of enlarging the size of the image as well. What you use depends on what you want to do.

For example -extent is very fast and nasty
-slice and add to an edge or insert rows and columns of pixels
-border as you know adds to both sides
-frame adds a colored frame

You can even use -repage OR -crop with a \! flag THEN -flatten, the image to fill it out to the added/changed virtual canvas.

Enjoy...
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:

Post by RQuadling »

Nasty is OK. It is doing the job I want.

I'm a true novice at IM so I still don't see why the option of -compress Group4 doesn't do all the things necessary to make the file a Group4 compressed tiff file!

Whatever IM is doing that restricts the file being a G4 Tiff should be removed when the command says make is a G4 TIFF. If that means -flatten -monochrome -standonyourhead -singnationalanthem, then so be it. I asked for a G4. I want a G4! Makes sense really.

As I doubt that will change, IM SHOULD at least tell me why it is NOT going to do what I asked (i.e. G4 cannot be done because image must be -flatten -monochrome -standonyourhead -singnationalanthem - sort of thing).

Useful!


Having said that, if you can show me an example for my file of a faster way of working, then I would be very grateful.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I agree that if -compress Group4 is requested and it can not be handled for some reason a warning should be given. In this case probably about a 'alpha channel being ignored' and it ignored the alpha anyway, just like Im does for JPEG (though without warning).

That is if the image has semi-transprant pixels, warn the user. for TIFF Group4 compression.

A simular warning for JPEG may also be good.

GIF warning about semi-transparency on the other hand may be a little too much.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply