Page 1 of 1

Gradient

Posted: 2016-04-10T01:31:19-07:00
by zemlik
hello,
I want to make and fill a rectangle with black on the left gradating to white on the right.
What is the syntax to get that ?
In Imagemagick there is

Code: Select all

convert  -size 100x100 gradient:  gradient.jpg 
cheers

Re: Gradient

Posted: 2016-04-10T06:05:06-07:00
by snibgo
convert -size 100x100 gradient: -rotate 90 gradient.jpg

Re: Gradient

Posted: 2016-04-10T07:18:51-07:00
by zemlik
Does that work in Perl ?

Re: Gradient

Posted: 2016-04-10T08:10:43-07:00
by snibgo
No reason why not, but I don't use Perl, sorry.

Re: Gradient

Posted: 2016-04-11T12:42:51-07:00
by zemlik
well you know different syntax

Re: Gradient

Posted: 2016-04-11T12:52:38-07:00
by snibgo
The documentation http://www.imagemagick.org/script/perl-magick.php gives a "Rotate" method, so it looks easy enough.

Creating a "gradient:", then applying a rotate, is effectively two operations. It may be faster to use "sparse-color".

Re: Gradient

Posted: 2016-04-11T14:37:35-07:00
by fmw42
In command line mode, there are now enhanced gradients with built-in rotations. See http://www.imagemagick.org/script/gradient.php. But I do not know if they have been folded over to PerlMagic or any other API.

Re: Gradient

Posted: 2016-04-12T05:22:14-07:00
by zemlik
It is just for me, I am playing with different things so there is no real rush.
I would like everything to be in the one file.
I could not see anything about gradient in any of the perl help documents/sites.

Re: Gradient

Posted: 2016-04-12T05:32:55-07:00
by snibgo
The documentation http://www.imagemagick.org/script/perl-magick.php shows how to create images from scratch. For example:

Code: Select all

$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->ReadImage('canvas:white');
If you want a gradient instead of a solid canvas, I expect you can use:

Code: Select all

$image->ReadImage('gradient:');