A website I'm working on has a functionality to upload images. After uploading, a thumbnail is generated and saved to the 'uploads' folder. It all works perfectly until I try to upload panoramas taken with an iPhone. These images are about 11,000 px wide which I think is the problem.
First question: What variable or parameter limits the creation of thumbnails? Is this issue fixable?
Second question: I've put the part that stopped working in a try & catch but the php code just doesn't execute anything after the thumbnail creating part. How do I make it do something else when this part of the code is not working?
I think the problem lies somewhere within the imagecopyresampled but I'm not sure. I hope someone has more experience with this than I do.
$ds = DIRECTORY_SEPARATOR;
$storeFolder = '../uploads/';
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
$date = new DateTime();
$newFileName = $date->getTimestamp().$_FILES['file']['name'];
$targetFile = $targetPath. $newFileName;
move_uploaded_file($tempFile,$targetFile);
$thumbStoreFolder = '../thumbs/';
$thumbPath = dirname( __FILE__ ) . $ds. $thumbStoreFolder . $ds;
$thumbnail = $thumbPath.'thumb'.$newFileName;
list($width,$height) = getimagesize($targetFile);
if($width >= $height) {
$thumb_width = 300;
$ratio = $width / $thumb_width;
$thumb_height = $height / $ratio;
} else {
$thumb_height = 300;
$ratio = $height / $thumb_height;
$thumb_width = $width / $ratio;
}
$thumb_create = imagecreatetruecolor($thumb_width,$thumb_height);
$source = imagecreatefromjpeg($targetFile);
imagecopyresampled($thumb_create,$source,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
imagejpeg($thumb_create,$thumbnail);
}