Im having a problem with my image uploading script. On some pictures uploaded, the main picture will upload fine, but the thumbnail will not create.
The filetype is of .JPG which is allowed, but for some reason the thumbnail just wont create on some .JPG's
Here is the script
## Set Known Photo Types
$known_photo_types = array(
'image/pjpeg' => 'jpg',
'image/jpeg' => 'jpg',
'image/jpeg' => 'JPG',
'image/pjpeg' => 'JPG',
'image/gif' => 'gif',
'image/gif' => 'GIF',
'image/png' => 'png',
'image/x-png' => 'png'
);
// GD Function List
$gd_function_suffix = array(
'image/pjpeg' => 'JPEG',
'image/jpeg' => 'JPEG',
'image/gif' => 'GIF',
'image/png' => 'PNG',
'image/x-png' => 'PNG'
);
// Store the orignal file
$copy = copy($photos_uploaded['tmp_name'], $images_dir."/".$filename);
if(!$copy) echo "copy failed";
// Let's get the Thumbnail size
$size = GetImageSize( $images_dir."/".$filename );
if($size[0] > $size[1])
{
$thumbnail_width = 100;
$thumbnail_height = (int)(100 * $size[1] / $size[0]);
}
else
{
$thumbnail_width = (int)(100 * $size[0] / $size[1]);
$thumbnail_height = 100;
}
// Build Thumbnail with GD 2
$function_suffix = $gd_function_suffix[$filetype];
$function_to_read = "ImageCreateFrom".$function_suffix;
$function_to_write = "Image".$function_suffix;
// Read the source file
$source_handle = $function_to_read($images_dir."/".$filename);
if($source_handle)
{
// Let's create an blank image for the thumbnail
$destination_handle = ImageCreateTrueColor ( $thumbnail_width, $thumbnail_height );
// Now we resize it
ImageCopyResampled( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] );
}
// Let's save the thumbnail
$function_to_write( $destination_handle, $images_dir."/tb_".$filename,95 );
ImageDestroy($destination_handle );
//
Is their anything stopping this? or what do you think could be causing this?