in reply to GD resize problems

This almost certainly isn't a GD related problem, but rather a problem with your file handling code. Specifically:

while ( <$filehandle> ){ print UPLOADFILE; }

While that will work fine for text files containing lines, it will likely screw up for image files that don't contain lines.

I'd suggest you make that:

{ local $/ = \65536; local $\; while ( <$filehandle> ){ print UPLOADFILE; } }

And see how you get on.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: GD resize problems
by horbor (Novice) on Jan 17, 2011 at 13:27 UTC

    Thank you one more time for your reply to my problem, BrowserUK. Just 20 mins back my friend proposed to use GD from the very beginning to save the original file and then use it to resize. And it worked! So now it is:

    my $method = $gd_ext{$extension}; my $original = GD::Image->$method($filehandle,1) or die "Can't load original $sourcename: $!"; open(FH, ">".$site->{cfg}{var}{full_content_path}.$site->{cfg} +{images}{original_dir}.$sourcename) or die "Cannot open image file $!"; binmode(FH); print FH $original->jpeg(100); close(FH);

    Have a nice day!

Re^2: GD resize problems
by horbor (Novice) on Jan 17, 2011 at 12:30 UTC
    Thank you BrowserUK for your reply! Unfortunately it doesn't work for me. The same error "Premature end of JPEG file". Maybe you have other suggestions?