how to build a center black gradient?

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
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

how to build a center black gradient?

Post by linjuming »

Image
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to build a center black gradient?

Post by linjuming »

Image


pattern.png:
Image

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 " .
		"( gradient:black-#808080-black -alpha set -channel A -evaluate set 80% -gravity north ) -compose overlay -composite " .
		"page.png";

exec($cmd);

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



?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to build a center black gradient?

Post by fmw42 »

convert -size 20x256 gradient: -rotate 90 -solarize 50% -level 0,50% -negate tmp1.png

or for less contrast

convert -size 20x256 gradient: -rotate 90 -solarize 50% -level 0,50% -negate +level 0,75% tmp2.png

see http://www.imagemagick.org/Usage/color_mods/#solarize and http://www.imagemagick.org/Usage/color_mods/#level


alternately

convert \( -size 20x128 gradient:"gray(25%)-gray(50%)" -rotate 90 \) \( +clone -flop \) +append tmp3.png


Note the center pixel will be duplicated in these cases. If you don't want that, then you need to use -shave or -chop. See http://www.imagemagick.org/Usage/crop/
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to build a center black gradient?

Post by linjuming »

very nice example ,thank you very much
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to build a center black gradient?

Post by anthony »

Do you want a 'sharp' center or a smooth center?

See IM Examples,canvas creation, gradients
http://www.imagemagick.org/Usage/canvas/#gradient

also look at the gradient created for a 'tile-shift' photo effect
http://www.imagemagick.org/Usage/photos/#tilt_shift
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply