Lid |
|
Beste,
Momenteel schrijf ik een script dat grote bestanden upload via SWF...
Van de originele bestanden wordt een thumbnail gemaakt op de webserver.
De originele bestanden worden weggeschreven naar onze externe FTP-server.
Dit werkt perfect,alleen bij grote bestanden van 60mb en groter (jpg) maakt hij geen thumbnail... Hoe zou dit komen en welke oplossing bieden jullie hiervoor ?
function ThumbFoto($fileSrc,$name)
{
$order_id = $_GET['get'];
$thumb_width = 150;
// Determining file extention
$ext = strtolower( substr($fileSrc, strrpos($fileSrc, ".")) );
if($ext == ".png") {
$base_img = ImageCreateFromPNG($fileSrc);
} else if(($ext == ".jpeg") || ($ext == ".jpg")) {
$base_img = ImageCreateFromJPEG($fileSrc);
} else if($ext == ".gif") {
$base_img = ImageCreateFromGIF($fileSrc);
}
// If the image is broken, skip it?
if (!$base_img) {
return false;
exit;
}
// Get image sizes from the image object we just created
$img_width = imagesx($base_img);
$img_height = imagesy($base_img);
$new_height = $img_height / ($img_width / $thumb_width);
// Working out thumb height
//$ratio = $img_height / $img_width;
//$thumb_height = $thmb_width * $ratio;
$thumb_img = ImageCreateTrueColor($thumb_width, $new_height);
ImageCopyResampled($thumb_img, $base_img, 0, 0, 0, 0, $thumb_width, $new_height, $img_width, $img_height);
if( $ext == ".png" ) {
ImagePNG($thumb_img,"thumbs/".$order_id.$name);
} else if (($ext == ".jpeg") || ($ext == ".jpg")) {
ImageJPEG($thumb_img, "thumbs/".$order_id.$name);
} else if ($ext == ".gif") {
ImageGIF($thumb_img, "thumbs/".$order_id.$name);
}
// Clean up our images
unlink($thumb_img);
ImageDestroy($base_img);
ImageDestroy($thumb_img);
}
function ThumbFoto($fileSrc,$name) { $order_id = $_GET['get']; $thumb_width = 150; // Determining file extention if($ext == ".png") { $base_img = ImageCreateFromPNG($fileSrc); } else if(($ext == ".jpeg") || ($ext == ".jpg")) { $base_img = ImageCreateFromJPEG($fileSrc); } else if($ext == ".gif") { $base_img = ImageCreateFromGIF($fileSrc); } // If the image is broken, skip it? if (!$base_img) { return false; } // Get image sizes from the image object we just created $img_width = imagesx($base_img); $img_height = imagesy($base_img); $new_height = $img_height / ($img_width / $thumb_width); // Working out thumb height //$ratio = $img_height / $img_width; //$thumb_height = $thmb_width * $ratio; $thumb_img = ImageCreateTrueColor($thumb_width, $new_height); ImageCopyResampled($thumb_img, $base_img, 0, 0, 0, 0, $thumb_width, $new_height, $img_width, $img_height); if( $ext == ".png" ) { ImagePNG($thumb_img,"thumbs/".$order_id.$name); } else if (($ext == ".jpeg") || ($ext == ".jpg")) { ImageJPEG($thumb_img, "thumbs/".$order_id.$name); } else if ($ext == ".gif") { ImageGIF($thumb_img, "thumbs/".$order_id.$name); } // Clean up our images ImageDestroy($base_img); ImageDestroy($thumb_img); }
if($upload)
{
$query = mysql_query("INSERT INTO printtoplate_bestelling (bestand,order_id) VALUES ('".$targetFile."','".$order_id."')");
$contents = ftp_nlist($conn_id, $map."/".$order_id);
foreach ($contents as $value)
{
$ext = pathinfo($value);
$new_ext = $ext['extension'];
$exten = strtolower($new_ext);
if($exten =='jpg' || $exten =='png' || $exten =='jpeg') // aanmaken van thumbnails
{
ThumbFoto("***/temp_files/".$order_id."/".$value,$value);
mysql_query("UPDATE printtoplate_bestelling SET tmp_bestand='".$order_id.$value."' WHERE bestand='".$value."'");
}
else{
mysql_query("UPDATE printtoplate_bestelling SET tmp_bestand='".$order_id.$value."' WHERE bestand='".$value."'");
}
}
}
if($upload) { $query = mysql_query("INSERT INTO printtoplate_bestelling (bestand,order_id) VALUES ('".$targetFile."','".$order_id."')"); $contents = ftp_nlist($conn_id, $map."/".$order_id); foreach ($contents as $value) { $new_ext = $ext['extension']; if($exten =='jpg' || $exten =='png' || $exten =='jpeg') // aanmaken van thumbnails { ThumbFoto("***/temp_files/".$order_id."/".$value,$value); mysql_query("UPDATE printtoplate_bestelling SET tmp_bestand='".$order_id.$value."' WHERE bestand='".$value."'"); } else{ mysql_query("UPDATE printtoplate_bestelling SET tmp_bestand='".$order_id.$value."' WHERE bestand='".$value."'"); } } }
|