All,
I'm trying to automatically generate a page header image that simulates a top-of-page tab. Eventually I want to be able to conveniently alter colors and regenerate it.
I first used convert.exe in discreet steps to create the pieces and then combine them. This works great. (see goodheader.pngbelow).
But I really would prefer to combine it all into a single invocation of convert without using temporary files. If I do so, I get a slightly different result -- look at the right edge of the tab, and you can see ugly aliasing apparently leftover from the mask.
I think I probably need to adjust the -alpha on|off|... setting somewhere in the process, but I've tried everything I can think of.
My batch file is listed below. My results may temporarily be viewed at:
http://keveney.com/test/test.html
I'm using version 6.4.2 08/14/08.
Any advice?
Should I post this as a bug?
-Matt
---- My Windows batch file -----
rem make header image
rem
rem faint gradient background
rem 'convex' gradient nav bar
rem
rem Mask for the tab
rem
rem (I think the fill color should not be relevant here, since were' only going to use the
rem alpha channel in subsequent operations. I make it blue so I can easily see it in testing.)
rem
convert^
-size 900x100^
xc:none^
-draw "fill blue stroke-width 0 path 'M 0,100 0,75 600,75 C 620,75 630,100 650,100 Z'"^
mask.png
rem Gradient for background
rem
convert^
-size 900x100^
gradient:#FFF-#FDD^
backgradient.png
rem Gradient for tab itself
rem
convert^
-size 700x25^
gradient:#F88-#F00^
tabgradient.png
rem Create cutout in background
rem
convert^
backgradient.png^
mask.png^
-alpha on^
-compose dst_out^
-composite^
cutout.png
rem Create header from files (this works great!)
rem
convert^
-gravity southwest^
cutout.png^
tabgradient.png^
-compose dst_over^
-composite^
goodheader.png
rem Do it all in one step. (This gives weird aliasing on right edge of tab!)
rem
convert^
-size 900x100^
gradient:#FFF-#FDD^
^
xc:none^
-draw "fill blue stroke-width 0 path 'M 0,100 0,75 600,75 C 620,75 630,100 650,100 Z'"^
-alpha on^
-compose dst_out^
-composite^
^
-size 700x25^
gradient:#F88-#F00^
-gravity southwest^
-compose dst_over^
-composite^
^
badheader.png
Odd aliasing behavior - doesn't happen with separate files
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Odd aliasing behavior - doesn't happen with separate files
You need to parenthesize the operations so that they don't interfere with one another.
The way I approach it is to start with the last convert command and work backwards:
Now parenthesize each of the input filenames taking care to put spaces around the parentheses:
Now replace tabgradient.png with the convert operations which made it:
Do the same for cutout.png:
This has introduced two new input filenames so parenthesize them:
and now replace those filenames as well:
and let it rip. It produces the "good" version of the final output file, or it did for me anyway .
Pete
The way I approach it is to start with the last convert command and work backwards:
Code: Select all
convert -gravity southwest cutout.png tabgradient.png -compose dst_over -composite goodheader.png
Code: Select all
convert -gravity southwest ( cutout.png ) ( tabgradient.png ) ^
-compose dst_over -composite goodheader.png
Code: Select all
convert -gravity southwest ( cutout.png ) ( -size 700x25 gradient:#F88-#F00 ) ^
-compose dst_over -composite goodheader.png
Code: Select all
convert -gravity southwest ( backgradient.png mask.png -alpha on -compose dst_out -composite ) ^
( -size 700x25 gradient:#F88-#F00 ) -compose dst_over -composite goodheader.png
Code: Select all
convert -gravity southwest ( ( backgradient.png ) ( mask.png ) -alpha on -compose dst_out -composite ) ^
( -size 700x25 gradient:#F88-#F00 ) -compose dst_over -composite goodheader.png
Code: Select all
convert -gravity southwest ( ( -size 900x100 gradient:#FFF-#FDD ) ^
( -size 900x100 xc:none^
-draw "fill blue stroke-width 0 path 'M 0,100 0,75 600,75 C 620,75 630,100 650,100 Z'" ) ^
-alpha on -compose dst_out -composite ) ^
( -size 700x25 gradient:#F88-#F00 ) ^
-compose dst_over -composite goodheader.png
Pete
Re: Odd aliasing behavior - doesn't happen with separate files
Excellent! Thank you!
In the mean time, I figured out that I can also work around the problem by negating my mask and adjusting the compose parameter appropriately. The following batch file gives good results with or without the temporary files.
I haven't examined the logic in depth, but I'll bet that the inverted mask technique somehow works even with the operations in the un-grouped sequence.
-Matt
---- My batch file that works around the problem -----
rem make header image
rem
rem faint gradient background
rem 'convex' gradient nav bar
rem
rem First create mask for the tab
rem
rem (I think the fill color should not be relevant here, since were' only going to use the
rem alpha channel in subsequent operations. I make it blue so I can easily see it in testing.)
rem trying a 'negative' mask
rem
convert^
-size 900x100^
xc:none^
-draw "fill blue stroke-width 0 path 'M 0,0 0,75 600,75 C 620,75 630,100 650,100 L 900,100 900,0 Z'"^
mask.png
rem gradient for background
rem
convert^
-size 900x100^
gradient:#FFF-#FDD^
backgradient.png
rem gradient for tab itself
rem
convert^
-size 700x25^
gradient:#F88-#F00^
tabgradient.png
rem create cutout in background
rem
convert^
mask.png^
backgradient.png^
-alpha on^
-compose atop^
-composite^
cutout.png
rem create header from files (this works great!)
rem
convert^
-gravity southwest^
cutout.png^
tabgradient.png^
-compose dst_over^
-composite^
goodheader.png
rem Do it all in one step.
rem
rem (This gives weird aliasing on right edge of tab)
rem
convert^
-gravity southwest^
-size 900x100^
xc:none^
-draw "fill blue stroke-width 0 path 'M 0,0 0,75 600,75 C 620,75 630,100 650,100 L 900,100 900,0 Z'"^
-size 900x100^
gradient:#FFF-#FDD^
-alpha on^
-compose atop^
-composite^
-size 700x25^
gradient:#F88-#F00^
-compose dst_over^
-composite^
badheader.png
In the mean time, I figured out that I can also work around the problem by negating my mask and adjusting the compose parameter appropriately. The following batch file gives good results with or without the temporary files.
I haven't examined the logic in depth, but I'll bet that the inverted mask technique somehow works even with the operations in the un-grouped sequence.
-Matt
---- My batch file that works around the problem -----
rem make header image
rem
rem faint gradient background
rem 'convex' gradient nav bar
rem
rem First create mask for the tab
rem
rem (I think the fill color should not be relevant here, since were' only going to use the
rem alpha channel in subsequent operations. I make it blue so I can easily see it in testing.)
rem trying a 'negative' mask
rem
convert^
-size 900x100^
xc:none^
-draw "fill blue stroke-width 0 path 'M 0,0 0,75 600,75 C 620,75 630,100 650,100 L 900,100 900,0 Z'"^
mask.png
rem gradient for background
rem
convert^
-size 900x100^
gradient:#FFF-#FDD^
backgradient.png
rem gradient for tab itself
rem
convert^
-size 700x25^
gradient:#F88-#F00^
tabgradient.png
rem create cutout in background
rem
convert^
mask.png^
backgradient.png^
-alpha on^
-compose atop^
-composite^
cutout.png
rem create header from files (this works great!)
rem
convert^
-gravity southwest^
cutout.png^
tabgradient.png^
-compose dst_over^
-composite^
goodheader.png
rem Do it all in one step.
rem
rem (This gives weird aliasing on right edge of tab)
rem
convert^
-gravity southwest^
-size 900x100^
xc:none^
-draw "fill blue stroke-width 0 path 'M 0,0 0,75 600,75 C 620,75 630,100 650,100 L 900,100 900,0 Z'"^
-size 900x100^
gradient:#FFF-#FDD^
-alpha on^
-compose atop^
-composite^
-size 700x25^
gradient:#F88-#F00^
-compose dst_over^
-composite^
badheader.png