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: 30
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Gradient

Post by zemlik » 2016-04-10T01:31:19-07:00

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

Re: Gradient

Post by snibgo » 2016-04-10T06:05:06-07:00

convert -size 100x100 gradient: -rotate 90 gradient.jpg
snibgo's IM pages: im.snibgo.com

zemlik
Posts: 30
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: Gradient

Post by zemlik » 2016-04-10T07:18:51-07:00

Does that work in Perl ?

snibgo
Posts: 9404
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gradient

Post by snibgo » 2016-04-10T08:10:43-07:00

No reason why not, but I don't use Perl, sorry.
snibgo's IM pages: im.snibgo.com

zemlik
Posts: 30
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: Gradient

Post by zemlik » 2016-04-11T12:42:51-07:00

well you know different syntax

snibgo
Posts: 9404
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gradient

Post by snibgo » 2016-04-11T12:52:38-07:00

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: 22109
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Gradient

Post by fmw42 » 2016-04-11T14:37:35-07:00

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: 30
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: Gradient

Post by zemlik » 2016-04-12T05:22:14-07:00

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

Re: Gradient

Post by snibgo » 2016-04-12T05:32:55-07:00

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