I'm trying to get this ironed out to work with the Jpegs first, then I'm hoping it'll be pretty straightforward to get other formats working as well. The current problem seems to be at line 87. GD::Image -> trueColor(1) sends me to the error message. I've tried doing a bit of monkeying around with it, but to no avail so far. I'm a novice yet, so be gentle :-). Cheers, K.#!C:\Perl\bin\perl.exe -wT ## use strict; use warnings; use CGI; use CGI::Carp qw/fatalsToBrowser/; use File::Basename; $CGI::POST_MAX = 1024*5000; $CGI::DISABLE_UPLOADS = 0; my $query = CGI->new; my $safeCharacters = 'a-zA-Z0-9_.-'; my $uploadDirectory = 'C:/Apache/htdocs/notoriousteaze.com/Images/Temp +'; my $originalImage = $query->param("Image"); my ($filename, undef, $ext) = fileparse($originalImage, qr(\..*)); $filename .= $ext; $filename =~ tr/ /_/; $filename =~ s/[^$safeCharacters]//g; if ($filename =~ /^([$safeCharacters]+)$/) { $filename = $1; } else { error("That file name doesnt work for me. $filename"); } my $uploadFilename = $query->upload("Image"); open(UPLOADFILE, ">$uploadDirectory/$filename") or error('Could Not Up +load File.'); while ( <$uploadFilename> ) { print UPLOADFILE; } close UPLOADFILE; my %resizeFileType = ( ".jpeg" => \&resizeJpeg, ".jpg" => \&resizeJpeg, ".gif" => \&resizeGif, ".png" => \&resizePng, ); if(defined ($resizeFileType{$ext})) { $resizeFileType{$ext}->($uploadDirectory, $filename); } else { error("Not seeing the filetype: $ext"); } sub error { my $error = shift(); print $query->header(), $query->start_html(-title=>'Error'), $error, $query->end_html; exit(0); } sub resizeJpeg($$) { use GD; my $newDirectory = 'C:/Apache/htdocs/notoriousteaze.com/Images/News' +; my $thumbDirectory = 'C:/Apache/htdocs/notoriousteaze.com/Images/New +sThumbs'; my $source = "$uploadDirectory/$filename"; my $target = "$newDirectory/$filename"; my $thumbTarget = "$thumbDirectory/$filename"; my $targetMaxX = 250; my $targetMaxY = 250; my $thumbMaxX = 80; my $thumbMaxY = 80; ##$source = shift(); ##$target = shift(); ##$thumbTarget = shift(); GD::Image->trueColor(1) or error("$source, filename: $filename"); ## +################This is where it seems to be conking out on me!!##### +############################################################ $buildable = newFromJpeg GD::Image($source, 1) or error('Could not c +reate Image.'); (my $width, my $height) = $buildable=> getbounds(); if ($width > $height) { $targetMaxY = $height / ($width / $targetMaxX); $thumbMaxY = $height / ($width / $thumbMaxX); } else { $targetMaxX = $width / ($height / $targetMaxY); $thumbMaxX = $width / ($height / $thumbMaxY); } my $resizedImage = newTrueColor GD::Image($targetMaxX, $targetMaxY); my $newThumb = newTrueColor GD::Image($thumbMaxX, $thumbMaxY); $resizedImage->copyResized($buildable, 0, 0, 0, 0, $targetMaxX, $tar +getMaxY, $width, $height); $resizedImage->interlaced('true'); $newThumb->copyResized($buildable, 0, 0, 0, 0, $thumbMaxX, $thumbMax +Y, $width, $height); $newThumb->interlaced('true'); open(DATEI, ">$target") or error('Could not write to target file.'); while ( <$resizedImage> ) { print DATEI; } close DATEI; open(DATEI, ">$thumbTarget") or error('Could not write to thumb file +.'); while ( <$resizedImage> ) { print DATEI; } close DATEI; } sub resizeGif { } sub resizePNG { }
In reply to GD::Image trueColor() hangup... by kalchas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |