Create a diagonal gradient
-
- Posts: 14
- Joined: 2014-02-28T00:30:49-07:00
- Authentication code: 6789
Create a diagonal gradient
$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,
$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,
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create a diagonal gradient
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.
Or you can do this with SparseColor Bilinear, by setting three colours at three corners of your image.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create a diagonal gradient
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)
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)
-
- Posts: 14
- Joined: 2014-02-28T00:30:49-07:00
- Authentication code: 6789
Re: Create a diagonal gradient
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create a diagonal gradient
I don't use Perl Magick, but the doc http://www.imagemagick.org/script/perl- ... -attribute says:
For "-define", have you tried something like:You can optionally add Image to any method name. For example, ReadImage() is an alias for method Read().
Code: Select all
$img->Set(gradient:vector=>'x1,y1, x2,y2');
snibgo's IM pages: im.snibgo.com
-
- Posts: 14
- Joined: 2014-02-28T00:30:49-07:00
- Authentication code: 6789
Re: Create a diagonal gradient
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?
$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?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create a diagonal gradient
But you didn't try what I actually wrote? It would come before the read, and would be useless after it.
snibgo's IM pages: im.snibgo.com
-
- Posts: 14
- Joined: 2014-02-28T00:30:49-07:00
- Authentication code: 6789
Re: Create a diagonal gradient
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.
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.
-
- Posts: 14
- Joined: 2014-02-28T00:30:49-07:00
- Authentication code: 6789
Re: Create a diagonal gradient
of is or (sorry I'm dutch)
-
- Posts: 14
- Joined: 2014-02-28T00:30:49-07:00
- Authentication code: 6789
Re: Create a diagonal gradient
I did not read the version question correctly..
I'm first going to upgrade ImageMagick and than try again.
I'm first going to upgrade ImageMagick and than try again.