Page 1 of 1

how to use the top composed img size as the result img size?

Posted: 2011-02-15T00:03:10-07:00
by linjuming
source pattern image:
Image

description:
Image

my code:

Code: Select all

<?php

$gb_pattern="pattern.png ";
$im=new imagick($gb_pattern);
$pattern_geo=$im->getimagegeometry();
$width=$pattern_geo["width"];
$height=$pattern_geo["height"];

$cmd =	"convert " .
		"-size {$width}x$height xc:#D18521 " .
		"( tile:$gb_pattern  -alpha set -channel A -evaluate set 50% ) -compose overlay -composite " .
		"page.png";

exec($cmd);

echo "<img src='pattern.png'/>";
echo "<br><br>";
echo "<img src='page.png'/>";

?>
1,use pure color to be background;
2,top img is the pattern.png ,use "-compose overlay" method;

can my code be any shorter? it seems a little long. any option using the top image's width and height as the composed img's?

Re: how to use the top composed img size as the result img s

Posted: 2011-02-15T21:05:23-07:00
by anthony
For "overlay" NO --- However Overlay is not designed to be used with transparency any way, so I have no idea what you are trying to do !!!!!



for "over" composition -- YES There are a number of options...

"convert " .
"-size {$width}x$height xc:#D18521 " .
"tile:$gb_pattern -define compose:args=50 -compose dissolve -composite " .
"page.png";

You are really doing a blending see.. http://www.imagemagick.org/Usage/compose/#blend

The disolve does the equivlent of a 50% transparency on the source image.

Actually is can also adjust the destination image too!


For opaque images (such as you have) you can use blend instead of dissolve, as in that case the results are the same (by the operators own definition). they only differ when transparency is involved in at least one of the images.


However as you are blending/dissolving a solid color you can also use -colorize

convert -size {$width}x$height tile:$gb_pattern -fill '#D18521' -colorize 50% page.png

See Colorize
http://www.imagemagick.org/Usage/color_mods/#colorize

Re: how to use the top composed img size as the result img s

Posted: 2011-02-15T21:32:11-07:00
by linjuming
great ,that helps much ! thanks !