im_fx_curves.pl

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
imagegem
Posts: 9
Joined: 2010-10-30T11:03:50-07:00
Authentication code: 8675308

im_fx_curves.pl

Post by imagegem »

Hello all

I am battling with the im_fx_curves.pl script provided on the imagemagick site. this is a perl script that allows you to make adjustments similar to photoshop curves: http://www.imagemagick.org/Usage/script ... _curves.pl

the only modification I have made to the script is changing the path to my perl, I am using macports perl, so the first line of this script is changed to #!/opt/local/bin/perl

I have installed Math::Polynomial from cpan

I am copying an example from inside the script, the example it gives is
./im_fx_curves.pl -p 0,20 100,90 20,80 70,50

When I run this dummy example, I get an error that says

usage: $q = $p->interpolate([$x1, $x2, ...], [$y1, $y2, ...]) at ./im_fx_curves.pl line 55

I do not know how to read perl, but line 55 of the perl script is
my $poly = Math::Polynomial::interpolate( @ARGV );

has anyone been able to get this script to work? Can any of you perl or imagemagick gurus see what I am doing wrong? Has any body got this script to successfully work for themselves?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: im_fx_curves.pl

Post by Bonzo »

You might need something else installed - are there any notes about needing any other software, minimum requirements etc. at the top of the code ?
imagegem
Posts: 9
Joined: 2010-10-30T11:03:50-07:00
Authentication code: 8675308

Re: im_fx_curves.pl

Post by imagegem »

Nope Bonzo, I see none. My perl script is exactly the same as this one, bar the path to perl
http://www.imagemagick.org/Usage/script ... _curves.pl
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: im_fx_curves.pl

Post by fmw42 »

I have a bash shell script, curves, that does something like PS. see the link below
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: im_fx_curves.pl

Post by Bonzo »

I see "This is a perl version using the Math::Polynomial library" :?

I pressume you need to install, activate or whatever you do with Perl.

Also in Anthony's other script:
# ASIDE:
#
# Gabe Schaffer created a perl version using the Math::Polynomial library
# (not a standard perl install) in "im_fx_curve.pl"
#
imagegem
Posts: 9
Joined: 2010-10-30T11:03:50-07:00
Authentication code: 8675308

Re: im_fx_curves.pl

Post by imagegem »

Thank you bonzo and fmw42 for taking the time to help me.

fmw42 I have got that shell script working. I am going to abandon the perl script. I will mess around with it now and hopefully come up with the results i am after.

Thank you once again.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: im_fx_curves.pl

Post by anthony »

imagegem wrote: I am copying an example from inside the script, the example it gives is
./im_fx_curves.pl -p 0,20 100,90 20,80 70,50

When I run this dummy example, I get an error that says

usage: $q = $p->interpolate([$x1, $x2, ...], [$y1, $y2, ...]) at ./im_fx_curves.pl line 55

I do not know how to read perl, but line 55 of the perl script is
my $poly = Math::Polynomial::interpolate( @ARGV );
I hosted the script in IM Examples. I just copied and pasted your command and it ran perfectly...

Code: Select all

im_fx_curves.pl -p 0,20 100,90 20,80 70,50
7.560*u^3-11.946*u^2+5.087*u+0.200
I have no idea why the Math::Polynomial::interpolate() function is producing a usage message, unless the module has changed since I last installed a personal copy.

I'll update and see if that is the case.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: im_fx_curves.pl

Post by anthony »

yes it looks like the Perl module changed....
This was found in the packages "examples/migration.pl" file...
Math::Polynomial version 1.000 broke backwards compatibility with earlier versions. This example demonstrates how legacy code using Math::Polynomial version 0.04 can be adapted to use a more current version of Math::Polynomial.
Worse still it appears to no longer follow a x1,y1, x2,y2, .... type of input for the points
switching to a [x1,x2,..], [y1,y2,...] input format... Arrggghhhhh.....

It will probably take some study to get the function fixed. Perhaps the original author, Gabe Schaffer, would help.

In the mean time you could try switching to the gnuplot function fitting method in "im_fx_curves"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: im_fx_curves.pl

Post by anthony »

Okay a new version that works has now been uploaded (give it an hour or so to appear)

The old one has been renamed "im_fx_curves_old.pl"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
imagegem
Posts: 9
Joined: 2010-10-30T11:03:50-07:00
Authentication code: 8675308

Re: im_fx_curves.pl

Post by imagegem »

thank you anthony
Post Reply