in reply to Resizing Uploaded Images?

Try posting the bit of code in qustion along with the exact error message it generates.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Resizing Uploaded Images?
by Anonymous Monk on Jun 10, 2003 at 21:53 UTC
    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!
      Oops, sorry. I forgot to login when I posted that.