You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From: J. Shirley
I am trying to write directly to the filehandle while working with
Imager, and I noticed an odd issue when I try to do so. If Imager
writes to the disk, then sends the file (or, to a scalar and sends
that via store_file or I print directly) it works just fine. Only
when I try to pass the filehandle in:
I get this error:
Can't locate object method "FILENO" via package
"MogileFS::NewHTTPFile" at /Library/Perl/5.8.8/darwin-thread-
multi-2level/Imager.pm line 1250, <Sock_tengu:6001> line 1.
The code in question there is:
my $fd = fileno($input->{fh});
unless (defined $fd) {
$self->_set_error("Handle in fh option not opened");
return;
}
# flush it
my $oldfh = select($input->{fh});
# flush anything that's buffered, and make sure anything else is
flushed
$| = 1;
select($oldfh);
return io_new_fd($fd);
So, the reasons are fairly sound (it writes to the fd, rather than a
perl filehandle) but... why? What is the advantage of this over other
things, and is it possible/desired to patch NewHTTPFile.pm to support
FILENO?
And here's my test:
use Imager;
use MogileFS::Client;
my $store = MogileFS::Client->new(
domain => 'example.com',
hosts => [ 'test:6001' ]
);
my $fh = $store->new_file("test_image", "user_media");
die "Can't allocate fh\n" unless $fh;
my $image = Imager->new;
$image->read( file => 'root/static/images/nav-back.png' )
or die "Can't read image: " . $image->errstr;
my $type = $image->tags( name => 'i_format' );
warn "Writing out $type to $fh\n";
my $scale = $image->scale(xpixels => 1280, ypixels => 1024, type =>
'min');
$scale->write( fh => $fh, type => $type );
unless ( $fh->close ) {
die "Error writing file: " . $store->errcode . ": " . $store-
>errstr;
}
Original issue reported on code.google.com by [email protected] on 2 Oct 2010 at 10:40
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
[email protected]
on 2 Oct 2010 at 10:40The text was updated successfully, but these errors were encountered: