anthony wrote:
However as both images are saved to jpg direct writing even without an internal clone should be fine..
Code: Select all
convert test.pdf -write test.jpg -thumbnail 64x64 thumbs/test_thumb.jpg
Hi,
I've just tried this and no luck. I am getting the right result on the first set of jpegs as they are coming out correctly, all pages, in the right directory with the right name. However, when navigating to the thumbs directory it's empty still, and the error log shows no signs of errors. I've attached images:
Both directories are created the same way with the same permissions (755). To help out I've attached my whole PHP script. It's an upload script which takes the file, creates folders puts it in those folders and then does the actions based on what filetype it is. I've also tried commenting out 90% of the script so all I'm left with is the "pdf" part and no luck, still just 1 set of images.
Code: Select all
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// $fileTypes = str_replace('*.','',$_REQUEST['fileext']);
// $fileTypes = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
// $fileParts = pathinfo($_FILES['Filedata']['name']);
// if (in_array($fileParts['extension'],$typesArray)) {
// Uncomment the following line if you want to make the directory if it doesn't exist
mkdir(str_replace('//','/',$targetPath), 0755, true);
mkdir($targetPath . "thumbs", 0755, true); // create thumbs dir
move_uploaded_file($tempFile,$targetFile);
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
// } else {
// echo 'Invalid file type.';
// }
}
$imgsize = getimagesize($targetFile);
switch(strtolower(substr($targetFile, -3))){
case "pdf":
$large = substr_replace($targetFile , 'jpg', strrpos($targetFile , '.') +1);
$thumbnail = "thumbs/".substr($large, 0, -4)."_thumb".strtolower(substr($large, -4));
$cmd = "$targetFile -write $large -thumbnail 64x64 $thumbnail ";
exec("convert $cmd "); // here's where I'm processing the above command, I've echo'd this out in a test file and it's exactly the same as above?
exit;
break;
case "jpg":
$image = imagecreatefromjpeg($targetFile);
break;
case "png":
$image = imagecreatefrompng($targetFile);
break;
case "gif":
$image = imagecreatefromgif($targetFile);
break;
default:
exit;
break;
}
$width = 60; //New width of image
$height = $imgsize[1]/$imgsize[0]*$width; //This maintains proportions
$src_w = $imgsize[0];
$src_h = $imgsize[1];
$picture = imagecreatetruecolor($width, $height);
imagealphablending($picture, false);
imagesavealpha($picture, true);
$bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h);
if($bool){
switch(strtolower(substr($targetFile, -3))){
case "jpg":
//header("Content-Type: image/jpeg");
$bool2 = imagejpeg($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4)));
break;
case "png":
//header("Content-Type: image/png");
imagepng($picture,$targetPath . substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4)));
break;
case "gif":
//header("Content-Type: image/gif");
imagegif($picture,$targetPath . substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4)));
break;
}
}
imagedestroy($picture);
imagedestroy($image);
echo '1'; // Important so upload will work on OSX
?>
Is there anyway of producing a verbose output of what's going on in this file? The file is a "silent" file as it's an upload process file, i.e. it never displays in the browser, just called as the result of a form so if I navigate to it directly I just get a load of errors, as you'd expect.
Cheers!