Re: Apache::Upload filehandle

2001-07-13 Thread Jay Buffington

Okay, that didn't fix the problem, but I have figured it out.  

Apache::Upload returns the filehandle as being blessed into Apache::Upload.  Whenever 
I send the filehandle to Image::Magick it thinks that it is a url of type Apache: 
(kind of like file: or http:).  If I bless the filehandle into a class that does not 
have a colon in it, it works.  

Here is my work around:

8... *snip*

my $fh = $r-upload-fh;
bless $fh, nonexistantclass;
my $error = $image-Read(file=$fh);

8... *snip*


I guess that this is a bug in Apache::Upload and Image::Magick.  Apache::Upload should 
not return the filehandle as blessed (I'm confused why it does this in the first 
place) and Image::Magick should do a better job checking to see if it has been sent a 
filehandle.  

Can this please be fixed in the next release of libapreq?

Thanks,
Jay Buffington 


On Thu, Jul 12, 2001 at 10:03:24AM -0400, darren chamberlain wrote:
 Jay Buffington [EMAIL PROTECTED] said something to this effect on 07/11/2001:
  I'm trying to use image magick to manipulate images that are
  uploaded via http.  To handle the uploaded images I'm using
  libapreq's Apache::Upload.
  
  I wrote the below simple example script to help explain my problem.
  
  When an image is uploaded to it I get this error in the apache
  error log: ImageMagick error: Warning 320: no delegate for this
  image format (:Upload=GLOB(0x873bcec)) [No such file or
  directory]
  
  I'm confused why this happens.  Could someone please explain
  this behaviour to me? 
 
 This looks like $r-upload-fh is being stringified, probably
 because of the context.  What happens when you assign the glob
 returned by $r-upload-fh to a lexical scalar, and then pass
 that into $image-Read()?  I hit this a few days ago, when
 passing a glob reference into a subroutine (not
 mod_perl-related), and this is the only thing that worked.
 
  
  package UploadFile;
  
  use Apache;
  use Apache::Request;
  use Apache::Constants qw(:common);
  use CGI qw(-compile :standard);
  use Image::Magick;
  
  sub handler {
  my $r = new Apache::Request(shift);
  
  if ($r-param('action') eq upload) {
  my $image = new Image::Magick;
 
 Add these changes: 
 
   my $fh = $r-upload-fh;
   my $error = $image-Read(file = $fh);
 
  $r-log_error(ImageMagick error: $error) if $error;
  $r-print(image geometry:  . join  x ,
$image-Get('width', 'height'));
  undef $image;
  }
  
  $r-print(start_html() . start_multipart_form() . Upload an image:  .
filefield(-name=uploadedfile) . submit(-name=action,
-value=upload) . end_form() . end_html());
  
  return OK;
  }
  
  1;
 
 (darren)
 
 -- 
 Death to all fanatics!



Re: Apache::Upload filehandle

2001-07-12 Thread darren chamberlain

Jay Buffington [EMAIL PROTECTED] said something to this effect on 07/11/2001:
 I'm trying to use image magick to manipulate images that are
 uploaded via http.  To handle the uploaded images I'm using
 libapreq's Apache::Upload.
 
 I wrote the below simple example script to help explain my problem.
 
 When an image is uploaded to it I get this error in the apache
 error log: ImageMagick error: Warning 320: no delegate for this
 image format (:Upload=GLOB(0x873bcec)) [No such file or
 directory]
 
 I'm confused why this happens.  Could someone please explain
 this behaviour to me? 

This looks like $r-upload-fh is being stringified, probably
because of the context.  What happens when you assign the glob
returned by $r-upload-fh to a lexical scalar, and then pass
that into $image-Read()?  I hit this a few days ago, when
passing a glob reference into a subroutine (not
mod_perl-related), and this is the only thing that worked.

 
 package UploadFile;
 
 use Apache;
 use Apache::Request;
 use Apache::Constants qw(:common);
 use CGI qw(-compile :standard);
 use Image::Magick;
 
 sub handler {
 my $r = new Apache::Request(shift);
 
 if ($r-param('action') eq upload) {
 my $image = new Image::Magick;

Add these changes: 

  my $fh = $r-upload-fh;
  my $error = $image-Read(file = $fh);

 $r-log_error(ImageMagick error: $error) if $error;
 $r-print(image geometry:  . join  x ,
   $image-Get('width', 'height'));
 undef $image;
 }
 
 $r-print(start_html() . start_multipart_form() . Upload an image:  .
   filefield(-name=uploadedfile) . submit(-name=action,
   -value=upload) . end_form() . end_html());
 
 return OK;
 }
 
 1;

(darren)

-- 
Death to all fanatics!



Apache::Upload filehandle

2001-07-11 Thread Jay Buffington

I'm trying to use image magick to manipulate images that are uploaded via http.  To 
handle the uploaded images I'm using libapreq's Apache::Upload.

I wrote the below simple example script to help explain my problem.

When an image is uploaded to it I get this error in the apache error log: 
ImageMagick error: Warning 320: no delegate for this image format 
(:Upload=GLOB(0x873bcec)) [No such file or directory]

I'm confused why this happens.  Could someone please explain this behaviour to me? 


package UploadFile;

use Apache;
use Apache::Request;
use Apache::Constants qw(:common);
use CGI qw(-compile :standard);
use Image::Magick;

sub handler {
my $r = new Apache::Request(shift);

if ($r-param('action') eq upload) {
my $image = new Image::Magick;
my $error = $image-Read(file=$r-upload()-fh());
$r-log_error(ImageMagick error: $error) if $error;
$r-print(image geometry:  . join  x , $image-Get('width', 'height'));
undef $image;
}

$r-print(start_html() . start_multipart_form() . Upload an image:  . 
filefield(-name=uploadedfile) . submit(-name=action, -value=upload) . 
end_form() . end_html());

return OK;
}

1;