[with apologies for repeat posting - previous message got truncated]
Hello

I'm trying to upload an image file from an html form and then process it
with ImageMagick.

I'm using code which has worked previously, but there seem to be probs with
it using Windows XP, ActivePerl-5.8.4.810,
ImageMagick-6.2.5.5-Q8-windows.dll

The html form is as follows:
<form 
        method="post" 
        name="form1" 
        ENCTYPE="multipart/form-data" 
        action="http://localhost/cgi-bin/site_cgi_dir/board_edit.cgi";>
--<snip>--
<input type="file" name="image_file" size="37"> .
--<snip>--
<form>

The perl script is using the following lines in uploading the image:

use CGI qw/:standard/;
use CGI::Carp;
use CGI::Carp qw(fatalsToBrowser);
use Image::Magick;

my $image_filename = $q->param('image_file');

if( $image_filename ne "" )
{
        $upload_dir =
"c:\\apache\\htdocs\\site_public_html\\images\\upload";
        $image_filename =~ s/.*[\/\\](.*)/$1/;

        # the line below returns NULL unless 'use strict;' is commented out

        $upload_filehandle = $q->upload('image_file');

        $the_filename = $image_filename;
        $save_filepath = "$upload_dir\\$the_filename";

        open UPLOADFILE, ">$save_filepath";
        binmode UPLOADFILE;

        # previously I've used this code to do the upload, but the
alternative below works OK
#       while( <$upload_filehandle> )
#       {
#               print UPLOADFILE;
#       }

        my( $buffer, $nread );
        my $totbytes = 0;
        while( $nread = read( $upload_filehandle, $buffer, 1024 ) ) 
        {
                $totbytes += $nread;
                print UPLOADFILE $buffer;
        }
        close UPLOADFILE;

        use strict;
        my $image = Image::Magick->new;
        my $saved_image = "$upload_dir\\$the_filename";
        open( IMAGE, "$saved_image" );
        binmode IMAGE;

        # perl crashes on this line - program runs to a normal exit if it is
commented out
        $x = $image->Read(file=>\*IMAGE);
        close(IMAGE);

        ( $filesize, $the_height, $the_width ) = $image->Get('filesize',
'height', 'width');

        open( LOGFILE, ">>log.txt" )
                or die "Couldn't open log.txt for appending $!\n";
        print LOGFILE "Filesize: [$filesize] Width: [$the_width] Height:
[$the_height]\n";
        close LOGFILE;
        undef $image;
}

Is anyone aware of any incompatibility in the versions of perl and
ImageMagick I'm using which would account for this problem?

Is there anything essentially incorrect (as opposed to inelegant) in the
code, where I might have been "getting away with it" with a previous
perl/ImageMagick version configuration, but where some error is now being
trapped?

The file is uploading OK, and being written by the perl script correctly to
the file path specified by $saved_image - I can open it in an image viewer.

The problem seems to occur as I try to bring the file into ImageMagick.

Many thanks for any useful suggestions or work-around ideas.

regards
Charles B


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please note: the text below is appended
automatically by my ISP to any mail routed
through their SMTP server. It should not
be interpreted as a personal endorsement.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~









512k Broadband £14.99 per month
Unlimited Downloads - No extra Costs
£14.99 per month (inc. VAT)
Order Now www.adsl4less.com
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to