Page 1 of 1
-compose and -layers merge
Posted: 2008-10-28T13:27:30-07:00
by bobrosoft
My command looks like this
Code: Select all
convert -virtual-pixel transparent \( files/patterns/sity/./main.png \)
\( /tmp/phpSmJ5D3 -matte +distort Perspective "0,0 283,230 0,480 283,362 480,480 318,350 480,0 318,187" \)
\( /tmp/phpSmJ5D3 -matte +distort Perspective "0,0 453,164 0,480 467,307 480,480 526,279 480,0 501,102" -compose color_dodge \)
\( /tmp/phpSmJ5D3 -swirl 90 -matte +distort Perspective "0,0 501,102 0,480 526,290 480,480 691,240 480,0 639,31" -compose multiply \)
-background white -layers merge -crop 700x465 +repage ./1.jpg
and everything is fine, but only last -compose (e.g. -compose multiply) apply to merged layers in resultant image.
How can I make all these -compose work?
Re: -compose and -layers merge
Posted: 2008-10-28T14:16:19-07:00
by fmw42
bobrosoft wrote:My command looks like this
Code: Select all
convert -virtual-pixel transparent \( files/patterns/sity/./main.png \)
\( /tmp/phpSmJ5D3 -matte +distort Perspective "0,0 283,230 0,480 283,362 480,480 318,350 480,0 318,187" \)
\( /tmp/phpSmJ5D3 -matte +distort Perspective "0,0 453,164 0,480 467,307 480,480 526,279 480,0 501,102" -compose color_dodge \)
\( /tmp/phpSmJ5D3 -swirl 90 -matte +distort Perspective "0,0 501,102 0,480 526,290 480,480 691,240 480,0 639,31" -compose multiply \)
-background white -layers merge -crop 700x465 +repage ./1.jpg
and everything is fine, but only last -compose (e.g. -compose multiply) apply to merged layers in resultant image.
How can I make all these -compose work?
-layers merge +repage should crop to minimum size so that there is no border, so you may not need -crop 700x465
If your main.png is the background larger than the others, you may not need -background white
I don't understand this step:
\( /tmp/phpSmJ5D3 -swirl 90 -matte +distort Perspective "0,0 501,102 0,480 526,290 480,480 691,240 480,0 639,31" -compose multiply \)
You need two images to do a -compose multiply and need to follow with a -composite.
Likewise the previous step ending in -compose color_dodge.
I don't think you can do -compose xxx without -composite and a second image.
See
http://www.imagemagick.org/Usage/compose/#compose
Re: -compose and -layers merge
Posted: 2008-10-28T15:02:03-07:00
by bobrosoft
All I want is to combine all layers like in Photoshop with "Blend mode", that (combine method) can change from layer to layer. These changes must apply on previous layers as in PS.
fmw42 wrote:-layers merge +repage should crop to minimum size so that there is no border, so you may not need -crop 700x465
in other commands (not this) images ( /tmp/phpSmJ5D3 ) transforms in other way and can out of bounds of needed size. Therefore crop present.
fmw42 wrote:You need two images to do a -compose multiply and need to follow with a -composite.
ie I can't merge these layers with -compose modes for each separate layer? I thought is one of the basic cases of merging layers and it must work in some way.. So give me another way, please
Re: -compose and -layers merge
Posted: 2008-10-28T15:33:06-07:00
by fmw42
bobrosoft wrote:All I want is to combine all layers like in Photoshop with "Blend mode", that (combine method) can change from layer to layer. These changes must apply on previous layers as in PS.
fmw42 wrote:-layers merge +repage should crop to minimum size so that there is no border, so you may not need -crop 700x465
in other commands (not this) images ( /tmp/phpSmJ5D3 ) transforms in other way and can out of bounds of needed size. Therefore crop present.
fmw42 wrote:You need two images to do a -compose multiply and need to follow with a -composite.
ie I can't merge these layers with -compose modes for each separate layer? I thought is one of the basic cases of merging layers and it must work in some way.. So give me another way, please
I really have no good idea of what you are trying to do with the compose operations. Please clarify what you are trying to do with -compose multiply and -compose color_dodge. If you are trying to use -compose with multiple images then you need to take -compose multiply and -compose color_dodge OUTSIDE the parenthesis, so that they can see the previous image. But be careful as you need to be clear what two images are being combined. You will also need to add -composite with each. Again, read the page
http://www.imagemagick.org/Usage/compose/ as it explains that you need two (or three) images to use the -compose operators.
You look to be doing something like at
http://www.imagemagick.org/Usage/distorts/#box3d. Read Anthony's comments about using -layers merge there regarding no need to crop as it does so automatically.
It might be best if you try to outline the steps you want to perform functionally along with which images you want to apply these steps, one-by-one. Then perhaps we can give you a better command line. Also provide your starting images.
Can you create each intermediate image separately and then combine them?
Re: -compose and -layers merge
Posted: 2008-10-29T12:46:14-07:00
by bobrosoft
Now my command looks like
Code: Select all
convert -virtual-pixel transparent \( ./files/patterns/sity/./main.png \) \
\( ./myphoto_480.jpg -matte +distort Perspective "0,0 283,230 0,480 283,362 480,480 318,350 480,0 318,187" \) -composite \
\( ./myphoto_480.jpg -matte +distort Perspective "0,0 453,164 0,480 467,307 480,480 526,279 480,0 501,102" \) -compose color_dodge -composite \
\( ./myphoto_480.jpg -swirl 90 -matte +distort Perspective "0,0 501,102 0,480 526,290 480,480 691,240 480,0 639,31" \) -compose multiply -composite \
-background white -crop 700x465 ./1.jpg
and -compose is work for every layer properly, but now appear other problem after using -composite -- all my transformed layers losts their positions (as after +repage) , was trimed by border and locate in top-left corner. How can I preserve positions of my transformed layers (as with
-layers merge method) ?
result of command
Re: -compose and -layers merge
Posted: 2008-10-29T14:26:41-07:00
by fmw42
bobrosoft wrote:Now my command looks like
Code: Select all
convert -virtual-pixel transparent \( ./files/patterns/sity/./main.png \) \
\( ./myphoto_480.jpg -matte +distort Perspective "0,0 283,230 0,480 283,362 480,480 318,350 480,0 318,187" \) -composite \
\( ./myphoto_480.jpg -matte +distort Perspective "0,0 453,164 0,480 467,307 480,480 526,279 480,0 501,102" \) -compose color_dodge -composite \
\( ./myphoto_480.jpg -swirl 90 -matte +distort Perspective "0,0 501,102 0,480 526,290 480,480 691,240 480,0 639,31" \) -compose multiply -composite \
-background white -crop 700x465 ./1.jpg
and -compose is work for every layer properly, but now appear other problem after using -composite -- all my transformed layers losts their positions (as after +repage) , was trimed by border and locate in top-left corner. How can I preserve positions of my transformed layers (as with
-layers merge method) ?
result of command
you may need to add -geometry before you -compose ... -composite commands to have the images placed where you want them.
Also you need to either add +repage after -crop or replace -crop with -layers merge.
Re: -compose and -layers merge
Posted: 2008-10-29T18:02:37-07:00
by anthony
There are TWO forms of image alignment or positioning used in Alpha Composition Operators...
virtual canvas offsets (used for merging multiple layers)
and geometry with gravity (used for two image composite).
See IM Examples, Alpha Compositing, Geometry, and Gravity Settings vs Page Offset
The -distort command supplied canvas offsets and images can be composed together using the flatten,mosaic, and merge layering methods. The latter is prefered as it works for negative offsets and results in another 'layer' image with virtual canvas offsets.
Unfortunately -composite ignores virual canvas offsets of 'layer' images, and uses -geometry and -gravity to position images.
The two techniques are basically incompatible.
ASIDE: One composition operator ( the multi-image sequence -layers composite operator) actually allows BOTH methods to be applied simultaneously. layer offsets being used for individual images, while composite geometry position (with gravity) is used for global positioning of the image sequences.
Re: -compose and -layers merge
Posted: 2008-10-30T04:04:12-07:00
by bobrosoft
fmw42 wrote:you may need to add -geometry before you -compose ... -composite commands to have the images placed where you want them.
yes, now I need to add -geometry, but I thought that other way exist. (against -layers merge, now I must to calc this offsets)
anthony wrote:Unfortunately -composite ignores virual canvas offsets of 'layer' images, and uses -geometry and -gravity to position images.
thanks for explain, now all are clear in my mind.
Thanks to all !
Re: -compose and -layers merge
Posted: 2008-10-30T18:24:45-07:00
by anthony
when using distorts it is better to use -layer merge to do the composition. That is because +distort preserves the layer offsets you used to position the resulting image.
see IM examples, Distorting Images,
Affine Box and Perspective Box examples, both of which use this method.
For get using the two image -composite. as you say you need to calculate the offsets. Worse still you also need to calculate and enlarge the destination image yourself The -layers merge does this itself automatically.