I have spent all day on this and can't figure out where I'm going wrong.
I am trying to resize some images to then write them to a folder so they can be zipped up and downloaded.
I can get the images to resize, rename and then save into another directory when using the phpThumb Demo -> phpThumb.demo.object.php. This is because the source image, phpThumb class, and the final image destination directory are all in the same folder.
However, I have now changed the directory structure so the phpThumb.class.php file is being called from the admin subdomain and the images need to be grabbed from the images subdomain and then saved to a directory in either the images or admin domains so I can get them later to write to a ZIP file.
I am just getting errors all the time and can't make out where to go from here. Can anyone help?
Here is the php:
require_once('../phpThumb/phpthumb.class.php');
// create phpThumb object
$phpThumb = new phpThumb();
// create 3 sizes of thumbnail
$thumbnail_widths = array(160, 320, 1000);
$capture_raw_data = false; // set to true to insert to database rather than render to screen or file (see below)
foreach ($thumbnail_widths as $thumbnail_width) {
// this is very important when using a single object to process multiple images
$phpThumb->resetObject();
// set data source -- do this first, any settings must be made AFTER this call
$phpThumb->setSourceFilename('/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg');
// PLEASE NOTE:
// You must set any relevant config settings here. The phpThumb
// object mode does NOT pull any settings from phpThumb.config.php
$phpThumb->setParameter('config_document_root', '/home/server/domains/images.testdomain.co.uk/public_html/');
$phpThumb->setParameter('config_cache_directory', '/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache/');
$phpThumb->setParameter('w', $thumbnail_width);
// set options (see phpThumb.config.php)
// here you must preface each option with "config_"
$phpThumb->setParameter('config_output_format', 'jpg');
$phpThumb->setParameter('config_imagemagick_path', '/usr/local/bin/convert');
// generate & output thumbnail
$output_filename = 'zip_temp/_'.$thumbnail_width.'.'.$phpThumb->config_output_format;
echo $output_filename;
if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it!
$output_size_x = ImageSX($phpThumb->gdimg_output);
$output_size_y = ImageSY($phpThumb->gdimg_output);
if ($output_filename || $capture_raw_data) {
if ($capture_raw_data && $phpThumb->RenderOutput()) {
// RenderOutput renders the thumbnail data to $phpThumb->outputImageData, not to a file or the browser
//mysql_query("INSERT INTO `table` (`thumbnail`) VALUES ('".mysql_escape_string($phpThumb->outputImageData)."') WHERE (`id` = '".$id."')");
} elseif ($phpThumb->RenderToFile($output_filename)) {
// do something on success
echo 'Successfully rendered:<br><img src="http://images.testdomain.co.uk/zip_temp/'.$output_filename.'">';
} else {
// do something with debug/error messages
echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
}
$phpThumb->purgeTempFiles();
} else {
$phpThumb->OutputThumbnail();
}
} else {
// do something with debug/error messages
echo 'Failed (size='.$thumbnail_width.').<br>';
echo '<div style="background-color:#FFEEDD; font-weight: bold; padding: 10px;">'.$phpThumb->fatalerror.'</div>';
echo '<form><textarea rows="10" cols="60" wrap="off">'.htmlentities(implode("\n* ", $phpThumb->debugmessages)).'</textarea></form><hr>';
}
}
AND HERE ARE THE ERRORS:
phpThumb() v1.7.11-201108081537 in file "phpthumb.class.php" on line 216
* phpThumb() v1.7.11-201108081537 in file "phpthumb.class.php" on line 216
* setSourceFilename(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) set $this->sourceFilename to "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg" in file "phpthumb.class.php" on line 262
* Leaving $this->config_imagemagick_path as (/usr/local/bin/convert) because !is_execuatable(realpath($this->config_imagemagick_path)) () in file "phpthumb.class.php" on line 1162
* file_exists(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1165
* file_exists_ignoreopenbasedir(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1166
* is_file(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1167
* is_executable(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1168
* ImageMagickThumbnailToGD() aborting because cannot find convert in $this->config_imagemagick_path (/usr/local/bin/convert), and `which convert` returned (which: no convert in (/bin:/usr/bin)) in file "phpthumb.class.php" on line 1198
* $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 923
* $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 934
* $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 951
* ResolveFilenameToAbsolute() NOT prepending $this->config_document_root (/home/server/domains/images.testdomain.co.uk/public_html/) to $filename (/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) resulting in ($AbsoluteFilename = "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg") in file "phpthumb.class.php" on line 1060
* $this->sourceFilename set to "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg" in file "phpthumb.class.php" on line 852
* phpThumb() v1.7.11-201108081537
http://phpthumb.sourceforge.net
Error messages disabled in file "phpthumb.class.php" on line 3847
* setCacheDirectory() starting with config_cache_directory = "/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache/" in file "phpthumb.class.php" on line 958
* setting config_cache_directory to realpath(/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache) = "/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache" in file "phpthumb.class.php" on line 986
* $this->config_cache_directory is not writable (/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache) in file "phpthumb.class.php" on line 997
* SetCacheFilename() _src set from md5($this->sourceFilename) "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg" = "688d3d8dc707794f27b6ef6db51ee9a2" in file "phpthumb.class.php" on line 3240
* SetCacheFilename() _par set from md5(_w160_dpi150_q75) in file "phpthumb.class.php" on line 3273
* starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 3035
* GetImageSize(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) says image is x in file "phpthumb.class.php" on line 3045
* GetImageSize("/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg") failed in file "phpthumb.class.php" on line 3078
* $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1315
* ImageMagickThumbnailToGD() aborting because ImageMagickCommandlineBase() failed in file "phpthumb.class.php" on line 2006
* ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3085
* SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 3014
* SetOrientationDependantWidthHeight() setting w="160", h="0" in file "phpthumb.class.php" on line 3030
* EXIF thumbnail extraction: (size=0; type=""; 0x0) in file "phpthumb.class.php" on line 3142
* starting SourceImageToGD() in file "phpthumb.class.php" on line 3400
* starting ImageCreateFromFilename(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) in file "phpthumb.class.php" on line 3315
* empty $filename or GetImageSize(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) failed in file "phpthumb.class.php" on line 3364
* Populating $rawimagedata in file "phpthumb.class.php" on line 3372
* cannot fopen(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) in file "phpthumb.class.php" on line 3383
* Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3471
* $this->gdimg_source is still empty in file "phpthumb.class.php" on line 3523
* ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3525
* phpThumb() v1.7.11-201108081537
http://phpthumb.sourceforge.net
Error messages disabled in file "phpthumb.class.php" on line 3847
* SourceImageToGD() failed in file "phpthumb.class.php" on line 342
open file phpthumb/phpthumb.class.php and change line 141:
to
Revisit the original page, and this time the actual error message should appear