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!

In reply to Re: Re: Resizing Uploaded Images? by Anonymous Monk
in thread Resizing Uploaded Images? by cirisme

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.