Multiply error? Or positioning error? or layer error?

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
perl@nevcal.com
Posts: 34
Joined: 2009-09-04T11:26:13-07:00
Authentication code: 8675309

Multiply error? Or positioning error? or layer error?

Post by perl@nevcal.com »

I'm not sure what is going wrong.

Code: Select all

Convert xc:white -resize 5250x3886! ( allnumbers.tif[0] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 ) -compose multiply -flatten  -compress group4 foo1.tif
foo1.tif

convert xc:white -resize 5250x3886! ( allnumbers.tif[1] -crop 2375x3885+125+125 +repage -repage 5250x3886+0+0 ) -compose multiply -flatten -compress group4 foo2.tif
foo2.tif

convert xc:white -resize 5250x3886! ( allnumbers.tif[0] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 ) -compose multiply -flatten ( allnumbers.tif[1] -crop 2375x3885+125+125 +repage -repage 5250x3886+0+0 ) -compose multiply -flatten -compress group4 foo3.tif
foo3.tif
So the command that builds foo1 works, and the command that builds foo2 works, and the command that builds foo3 doesn't. "works" in the sense that I get the results I expect. So this is an extracted test, I'm actually trying to number pages, but for testing, I am using a file of page numbers, and overlaying page 1 and page 2 (in the real code, I use a file of data, and a file of page numbers).

The file of page numbers, for reference, is at http://nevcal.com/temporary/allnumbers.tif. The Batch file above is also at http://nevcal.com/temporary/foo.bat, if that is helpful.

So I start with a white page, and overlay one page number. That works (foo1). I start with a white page, and overlay a different page number, with a slightly variant command. That works (foo2). When I put them together, the second page number doesn't show up. I don't if it is an effect of positioning, if multiply isn't working two times in a row, or if I'm stacking layers badly.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multiply error? Or positioning error? or layer error?

Post by fmw42 »

Remove the flatten. In unix it would be


convert xc:white -resize 5250x3886! \
\( allnumbers.tif[0] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 \) \
-compose multiply \
\( allnumbers.tif[1] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 \) \
-compose multiply -compress group4 foo3.tif
perl@nevcal.com
Posts: 34
Joined: 2009-09-04T11:26:13-07:00
Authentication code: 8675309

Re: Multiply error? Or positioning error? or layer error?

Post by perl@nevcal.com »

Hmm. Not quite. Removing the flattens produces a 3 page TIFF file. I want the content merged. I just tried removing the first flatten, but that didn't change the results... only the first page number shows up, instead of both of them.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multiply error? Or positioning error? or layer error?

Post by fmw42 »

try this


convert \( xc:white -resize 5250x3886! \) \
\( -clone 0 \( allnumbers.tif[0] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 \) \
-compose multiply -flatten \) \
\( -clone 0 \( allnumbers.tif[1] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 \) \
-compose multiply -flatten \) \
-delete 0 -compress group4 foo3.tif

in windows

convert ( xc:white -resize 5250x3886! ) ^
( -clone 0 ( allnumbers.tif[0] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 ) ^
-compose multiply -flatten ) ^
( -clone 0 ( allnumbers.tif[1] -gravity center -background white -extent 2375x3885 +repage -repage 5250x3886+0+0 ) ^
-compose multiply -flatten ) ^
-delete 0 -compress group4 foo3.tif
perl@nevcal.com
Posts: 34
Joined: 2009-09-04T11:26:13-07:00
Authentication code: 8675309

Re: Multiply error? Or positioning error? or layer error?

Post by perl@nevcal.com »

That was better, it produced the numbers where I wanted them, but had 2 pages in the result file, one with each number. An extra

-compose multiply -flatten

cured that.

The weird this is, I tried the original case again, and it now works, without having made changes... maybe it is something to do with my data files, I did change them around some. Anyway, the test case should have done the same thing, and didn't, but this modification does. Thanks for your help.
Post Reply