BEGIN {
require Exporter;
@ISA = qw(Exporter);
- $VERSION = '0.53';
+ $VERSION = '0.55';
eval {
require XSLoader;
XSLoader::load(Imager => $VERSION);
unless (defined wantarray) {
my @caller = caller;
- warn "to_rgb8() called in void context - to_rgb8() returns the cropped image at $caller[1] line $caller[2]\n";
+ warn "to_rgb8() called in void context - to_rgb8() returns the converted image at $caller[1] line $caller[2]\n";
return;
}
sub _get_reader_io {
my ($self, $input) = @_;
- if ($input->{io}) {
- return $input->{io}, undef;
- }
+ if ($input->{io}) {
+ return $input->{io}, undef;
+ }
elsif ($input->{fd}) {
return io_new_fd($input->{fd});
}
sub _get_writer_io {
my ($self, $input, $type) = @_;
- if ($input->{fd}) {
+ if ($input->{io}) {
+ return $input->{io};
+ }
+ elsif ($input->{fd}) {
return io_new_fd($input->{fd});
}
elsif ($input->{fh}) {
return $self;
}
+ my $allow_incomplete = $input{allow_incomplete};
+ defined $allow_incomplete or $allow_incomplete = 0;
+
if ( $input{'type'} eq 'tiff' ) {
my $page = $input{'page'};
defined $page or $page = 0;
- # Fixme, check if that length parameter is ever needed
- $self->{IMG}=i_readtiff_wiol( $IO, -1, $page );
+ $self->{IMG}=i_readtiff_wiol( $IO, $allow_incomplete, $page );
if ( !defined($self->{IMG}) ) {
$self->{ERRSTR}=$self->_error_as_msg(); return undef;
}
}
if ( $input{'type'} eq 'pnm' ) {
- $self->{IMG}=i_readpnm_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
+ $self->{IMG}=i_readpnm_wiol( $IO, $allow_incomplete );
if ( !defined($self->{IMG}) ) {
$self->{ERRSTR}='unable to read pnm image: '._error_as_msg();
return undef;
}
if ( $input{'type'} eq 'bmp' ) {
- $self->{IMG}=i_readbmp_wiol( $IO );
+ $self->{IMG}=i_readbmp_wiol( $IO, $allow_incomplete );
if ( !defined($self->{IMG}) ) {
$self->{ERRSTR}=$self->_error_as_msg();
return undef;
$self->_set_opts(\%input, "bmp_", $self)
or return undef;
if ( !i_writebmp_wiol($self->{IMG}, $IO) ) {
- $self->{ERRSTR}='unable to write bmp image';
+ $self->{ERRSTR} = $self->_error_as_msg;
return undef;
}
$self->{DEBUG} && print "writing a bmp file\n";
}
}
else {
- $ERRSTR = "Sorry, write_multi doesn't support $type yet";
- return 0;
+ if (@images == 1) {
+ unless ($images[0]->write(%$opts, io => $IO, type => $type)) {
+ return 1;
+ }
+ }
+ else {
+ $ERRSTR = "Sorry, write_multi doesn't support $type yet";
+ return 0;
+ }
}
}
return;
}
}
+ else {
+ my $img = Imager->new;
+ if ($img->read(%opts, io => $IO, type => $type)) {
+ return ( $img );
+ }
+ }
$ERRSTR = "Cannot read multiple images from $type files";
return;
unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
my %input=('x'=>0, 'y'=>0, @_);
- $input{string}||=$input{text};
+ defined($input{string}) or $input{string} = $input{text};
unless(defined $input{string}) {
$self->{ERRSTR}="missing required parameter 'string'";