if ($ex_version < 5.57) {
@ISA = qw(Exporter);
}
- $VERSION = '0.92';
+ $VERSION = '0.93';
require XSLoader;
XSLoader::load(Imager => $VERSION);
}
sub setsamples {
my $self = shift;
- my %opts = ( x => 0, offset => 0, @_ );
unless ($self->{IMG}) {
$self->_set_error('setsamples: empty input image');
return;
}
- my $data = $opts{data};
- unless(defined $data) {
+ my %opts = ( x => 0, offset => 0 );
+ my $data_index;
+ # avoid duplicating the data parameter, it may be a large scalar
+ my $i = 0;
+ while ($i < @_ -1) {
+ if ($_[$i] eq 'data') {
+ $data_index = $i+1;
+ }
+ else {
+ $opts{$_[$i]} = $_[$i+1];
+ }
+
+ $i += 2;
+ }
+
+ unless(defined $data_index) {
$self->_set_error('setsamples: data parameter missing');
return;
}
+ unless (defined $_[$data_index]) {
+ $self->_set_error('setsamples: data parameter not defined');
+ return;
+ }
my $type = $opts{type};
defined $type or $type = '8bit';
my $count;
if ($type eq '8bit') {
$count = i_psamp($self->{IMG}, $opts{x}, $opts{y}, $opts{channels},
- $data, $opts{offset}, $width);
+ $_[$data_index], $opts{offset}, $width);
}
elsif ($type eq 'float') {
$count = i_psampf($self->{IMG}, $opts{x}, $opts{y}, $opts{channels},
- $data, $opts{offset}, $width);
+ $_[$data_index], $opts{offset}, $width);
}
elsif ($type =~ /^([0-9]+)bit$/) {
my $bits = $1;
- unless (ref $data) {
+ unless (ref $_[$data_index]) {
$self->_set_error("setsamples: data must be an array ref for type not 8bit or float");
return;
}
$count = i_psamp_bits($self->{IMG}, $opts{x}, $opts{y}, $bits,
- $opts{channels}, $data, $opts{offset},
+ $opts{channels}, $_[$data_index], $opts{offset},
$width);
}
else {
$new->{IMG} = i_convert($self->{IMG}, $matrix);
unless ($new->{IMG}) {
# most likely a bad matrix
+ i_push_error(0, "convert");
$self->{ERRSTR} = _error_as_msg();
return undef;
}
L<Imager::Security> - brief security notes.
+=item *
+
+L<Imager::Threads> - brief information on working with threads.
+
=back
=head2 Basic Overview
L<Imager::Engines/"Matrix Transformations">,
L<Imager::Font/transform()>
-metadata, image - L<Imager::ImageTypes/"Tags">
+metadata, image - L<Imager::ImageTypes/"Tags">, L<Image::ExifTool>
mosaic - L<Imager::Filters/mosaic>
text, measuring - L<Imager::Font/bounding_box()>, L<Imager::Font::BBox>
+threads - L<Imager::Threads>
+
tiles, color - L<Imager::Filters/mosaic>
transparent images - L<Imager::ImageTypes>,
writing an image to a file - L<Imager::Files>
-=head1 THREADS
-
-Imager doesn't support perl threads.
-
-Imager has limited code to prevent double frees if you create images,
-colors etc, and then create a thread, but has no code to prevent two
-threads entering Imager's error handling code, and none is likely to
-be added.
-
=head1 SUPPORT
The best place to get help with Imager is the mailing list.
L<GD>(3), L<Image::Magick>(3), L<Graphics::Magick>(3),
L<Prima::Image>, L<IPA>.
+For manipulating image metadata see L<Image::ExifTool>.
+
If you're trying to use Imager for array processing, you should
probably using L<PDL>.