Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 48261
Status: resolved
Priority: 40/
Queue: Imager

People
Owner: TONYC [...] cpan.org
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.67
Fixed in: (no value)



Subject: read/open method should work as class methods.
Currently to read a single image file you do: my $im = Imager->new; $im->read(file => $foo) or die; a common mistake is to skip the error check: my $im = Imager->new; $im->read(file => $foo); which still leaves a non-null image in $im, even if the low level image object is missing. To reduce useless boilerplate, it should be possible to call read() as a class method which returns nothing on failure: my $im = Imager->read(file => $foo) or die; In this case, even if the error checking is ommitted, the error is obvious the next time a method is called on $im: my $im = Imager->read(file => $foo); $im->write(file => $bar); # immediate BOOM, since $im is undef Note that read_multi() is already a class method.
Imager->new() can now take file, fh etc parameters to read from that file.