[Magick-bugs] Add 'extract' attribute to PerlMagick [PATCH]
Beau E. Cox
beau.e.cox at gmail.com
Sat Jul 21 01:46:48 PDT 2007
Hi -
I would like to have the 'extract' attribute implemented
in PerlMagick; here is a patch for 6.3.5-2 that does
just that:
===========patch============
--- ../ImageMagick-6.3.5.untouched/PerlMagick/Magick.xs 2007-07-15
15:29:19.000000000 -1000
+++ ./PerlMagick/Magick.xs 2007-07-20 22:09:41.000000000 -1000
@@ -1274,6 +1274,12 @@
image->endian=(EndianType) sp;
break;
}
+ if (LocaleCompare(attribute,"extract") == 0)
+ {
+ if (info)
+ (void) CloneString(&info->image_info->extract,SvPV(sval,na));
+ break;
+ }
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
attribute);
break;
@@ -3964,6 +3970,13 @@
PUSHs(s ? sv_2mortal(s) : &sv_undef);
continue;
}
+ if (LocaleCompare(attribute,"extract") == 0)
+ {
+ if (info && info->image_info->extract)
+ s=newSVpv(info->image_info->extract,0);
+ PUSHs(s ? sv_2mortal(s) : &sv_undef);
+ continue;
+ }
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
attribute);
break;
============cut=============
I have used this script for testing; no problems encountered:
===========script===========
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use Image::Magick;
my $img = Image::Magick->new;
printf "get extract: %s\n", $img->get( "extract" ) || "undef";
$img->set( extract => "600x400+600+300", );
printf "get extract: %s\n", $img->get( "extract" ) || "undef";
$img->Read( "hatching.jpg", );
printf "%s: %sx%s\n", $img->get( qw( filename width height ) );
$img->Write( "extract.jpg" );
printf "%s: %sx%s\n", $img->get( qw( filename width height ) );
printf "get extract: %s\n", $img->get( "extract" ) || "undef";
undef $img;
============cut=============
My environment is:
os
Debian (unstable)
uname -a
Linux hanako 2.6.21-2-amd64 #1 SMP Tue Jul 10 21:39:38 \
UTC 2007 x86_64 GNU/Linux
gcc --version
gcc (GCC) 4.1.3 20070629 (prerelease) (Debian 4.1.2-13)
perl -v
This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi
Aloha => Beau;
More information about the Magick-bugs
mailing list