in reply to Re: Resizing Uploaded Images?
in thread Resizing Uploaded Images?

I've tried a bunch of different variations trying to get this to work(including saving it to a temp file, then telling GD what that temp file is). This is the current code:

#!E:\perl\bin\perl.exe -w

use CGI qw(:standard);
$savedir = "E:\\network\\apache2\\htdocs";
$query = new CGI;

use GD;

if ($file=param('filename')) {
  save_file();
} else {
  show_form();
}

sub show_form {
print $query->header();
print $query->start_html("File Uploading"),
      h1('File uploading'),
      $query->start_multipart_form(),
      p,
      "The file to upload:",
      p,
      $query->filefield(-name=>'filename',
                        -size=>45),
      p,
      $query->submit(-name=>'submit',
                     -value=>'Upload File'),
      $query->endform,
      $query->end_html;
}

sub save_file {
  $file2 = upload('filename');

  $im = new GD::Image($file2);
  $rim = new GD::Image(240,240);

  ($width,$height) = $im->getBounds();
  $rim->copyResized($im,0,0,0,0,$width,$height,240,240);
#close FILE;

#  print "Content-type: image/png\n\n";
  print "Content-type: text/html\n\n";

#  binmode STDOUT;
  print "$width $height";
#  print $rim->png;
}


I am printing the width and height to at least see if the image is being imported; but it obviously is not. The errors I get:

Tue Jun 10 15:46:23 2003 error client 192.168.200.3 Name "main::savedir" used only once: possible typo at E:/network/Apache2/cgi-bin/upload.pl line 4., referer: http://cir/cgi-bin/upload.pl
Tue Jun 10 15:46:23 2003 error client 192.168.200.3 Name "main::file" used only once: possible typo at E:/network/Apache2/cgi-bin/upload.pl line 9., referer: http://cir/cgi-bin/upload.pl
Tue Jun 10 15:46:23 2003 error client 192.168.200.3 Argument "E:\\network\\Apache2\\htdocs\\file.jpg" isn't numeric in subroutine entry at E:/network/Apache2/cgi-bin/upload.pl line 35., referer: http://cir/cgi-bin/upload.pl

I really would like to use something other than GD, but I have no choice.

Thanks for your help!

Replies are listed 'Best First'.
Re: Re: Re: Resizing Uploaded Images?
by cirisme (Initiate) on Jun 11, 2003 at 13:54 UTC
    Oops, sorry. I forgot to login when I posted that.