Reputation: 7746
I hate to ask this kind of question. But the images arent showing on my web server like they were on my local system.
PHP info http://www.classifiedtestbed.com/test.php
Example of missing images: http://www.classifiedtestbed.com/advertisements/2
My script is correct but I am thinking this could a apache or php problem please look at my phpinfo() and tell me if you see anything wrong.
The images should be processing from my tmp dir and moving to my uploads dir but that never happens...I get not errors in php_errors and have checked httd/error_log
Any suggestions would be super appreciated, thank you!
public function createTN($image) {
# Load Zebra Image Library
require_once public_path().'/uploads/Zebra_Image.php';
$destinationPath = public_path().'/uploads/thumbnails/';
$tn = new Zebra_Image();
$tn->source_path = $image->getRealPath();
$tn->target_path = $destinationPath.$this->name.'.jpg';
$tn->jpeg_quality = 60;
$tn->preserve_aspect_ratio = true;
$tn->enlarge_smaller_images = true;
$tn->resize(100, 100, ZEBRA_IMAGE_CROP_CENTER);
}
ps: file modes have been changed to 777 already
PHP Files are not moving from /tmp
public function createTN($image) {
# Load Zebra Image Library
require_once public_path().'/uploads/Zebra_Image.php';
$destinationPath = public_path().'/uploads/thumbnails/';
$tn = new Zebra_Image();
$tn->source_path = $image->getRealPath();
$tn->target_path = $destinationPath.$this->name.'.jpg';
$tn->jpeg_quality = 60;
$tn->preserve_aspect_ratio = true;
$tn->enlarge_smaller_images = true;
if (!$tn->resize(100, 100, ZEBRA_IMAGE_CROP_CENTER)) echo 'Error: ' . $tn->error;
echo 'Is file: ' . is_file($tn->source_path);
exit;
/*$tn->resize(100, 100, ZEBRA_IMAGE_CROP_CENTER);*/
}
Output: Error: 7Is file: 1
Upvotes: 0
Views: 276
Reputation: 8701
When somethings fails down, you can simply debug things step by step to see if they produce expected result. So in your case, that was a method $tn->resize(100, 100, ZEBRA_IMAGE_CROP_CENTER);
which is meant to resize an image and save it.
From zebra's source code we have:
* @return boolean Returns TRUE on success or FALSE on error.
*
* If FALSE is returned, check the {@link error} property to see what went
* wrong
*/
public function resize($width = 0, $height = 0, $method = ZEBRA_IMAGE_CROP_CENTER, $background_color = '#FFFFFF')
So obliviously, to find out what went wrong, you could simply test it like this:
if ( ! $tm->resize(..) ){
switch($tm->error){
// handle it somehow here
}
}
As for description for error codes, there's an official page
http://php.net/manual/en/book.image.php
CentOS7
yum install gd gd-devel php-gd
Upvotes: 1