Gradient

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
zemlik
Posts: 38
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Gradient

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gradient

Post by snibgo »

convert -size 100x100 gradient: -rotate 90 gradient.jpg
snibgo's IM pages: im.snibgo.com
zemlik
Posts: 38
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: Gradient

Post by zemlik »

Does that work in Perl ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gradient

Post by snibgo »

No reason why not, but I don't use Perl, sorry.
snibgo's IM pages: im.snibgo.com
zemlik
Posts: 38
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: Gradient

Post by zemlik »

well you know different syntax
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gradient

Post 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".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gradient

Post 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.
zemlik
Posts: 38
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: Gradient

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gradient

Post 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:');
snibgo's IM pages: im.snibgo.com
Post Reply