Page 1 of 1
Create a diagonal gradient
Posted: 2017-03-07T14:23:36-07:00
by mc_hendriks
$img=Image::Magick->new();
$img->Set(size=>'500x500');
$img->Read('gradient:green-red');
Gives a box with a linear gradient from left to right, I would like a linear gradient from top-left to bottom right in the same box.
If I use a Rotate than the complete box gets rotated.
Any hints are appreciated, I'm stuck here and can't find any decent documentation on this subject,
Re: Create a diagonal gradient
Posted: 2017-03-07T14:31:43-07:00
by snibgo
What version of IM? If from 6.9.2-5 onwards, try the techniques shown in
http://www.imagemagick.org/script/gradient.php
Or you can do this with SparseColor Bilinear, by setting three colours at three corners of your image.
Re: Create a diagonal gradient
Posted: 2017-03-07T17:18:27-07:00
by fmw42
try
ReadImage('gradient:green-red'); not Read('gradient:green-red');
see docs at
http://www.imagemagick.org/script/perl-magick.php (example for example for creating a white canvas is similar)
Re: Create a diagonal gradient
Posted: 2017-03-08T00:44:26-07:00
by mc_hendriks
I'm using version 6.6.9-7
IMHO: Aren't Read and ReadImage the same? They produce the same results.
I looked at
http://www.imagemagick.org/script/gradient.php
but how can I use these settings from perlmagick? For example:
-define gradient:vector=x1,y1, x2,y2
Re: Create a diagonal gradient
Posted: 2017-03-08T09:29:39-07:00
by snibgo
I don't use Perl Magick, but the doc
http://www.imagemagick.org/script/perl- ... -attribute says:
You can optionally add Image to any method name. For example, ReadImage() is an alias for method Read().
For "-define", have you tried something like:
Code: Select all
$img->Set(gradient:vector=>'x1,y1, x2,y2');
Re: Create a diagonal gradient
Posted: 2017-03-09T03:29:24-07:00
by mc_hendriks
After your reply I tried:
$img->Set("gradient:vector"=>"1,1 100,100");
$img->Set("gradient_vector"=>"1,1 100,100");
$img->Set(gradient_vector=>"1,1 100,100");
Before and after the $img->ReadImage('gradient:green-orange');
I also tried to put in in the ReadIMage itself, no luck so far.
Any ideas left?
Re: Create a diagonal gradient
Posted: 2017-03-09T03:42:10-07:00
by snibgo
But you didn't try what I actually wrote? It would come before the read, and would be useless after it.
Re: Create a diagonal gradient
Posted: 2017-03-09T03:48:31-07:00
by mc_hendriks
Of course I did, but perl doesn't like: $img->Set(gradient:vector=>'x1,y1, x2,y2');
You are not allowed to use a : in a hash key whithout enclosing with ' or "
so either .. Set('gradient:vector'=> ... of gradient_vector
But still no luck.
Re: Create a diagonal gradient
Posted: 2017-03-09T03:49:55-07:00
by mc_hendriks
of is or (sorry I'm dutch)
Re: Create a diagonal gradient
Posted: 2017-03-09T07:33:47-07:00
by mc_hendriks
I did not read the version question correctly..
I'm first going to upgrade ImageMagick and than try again.