I'm trying to flip an image with php gd function imageflip()
. I have GD installed. I'm using WAMP and codeigniter on Windows. (and it's kind of difficult to implement imagemagick on wamp - so I would prefer not to). imageflip() should work as I see it. I'm using PHP version 5.4.16.
Maybe I'm missing something...
from phpinfo()
:
gd
GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.4.10
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 8
PNG Support enabled
libPNG Version 1.2.50
WBMP Support enabled
XPM Support enabled
libXpm Version 30411
XBM Support enabled
Directive Local Value Master Value
gd.jpeg_ignore_ warning 0 0
I have this code:
foreach($products_settings as &$ps) {
$filename = $_SERVER['DOCUMENT_ROOT'] . $ps['product_file'];
$source_image = imagecreatefromjpeg($filename);
//Put source image-resource into array
$ps['source_image'] = $source_image;
}
and it works..
When I use imagerotate()
it works as well...
foreach($products_settings as &$ps) {
$filename = $_SERVER['DOCUMENT_ROOT'] . $ps['product_file'];
$source_image = imagecreatefromjpeg($filename);
//rotate image
$angle = $ps['product_angle'];
if (intval($angle) <> 0) {
$source_image = imagerotate($source_image, 360-$angle, imageColorAllocateAlpha($source_image, 255, 255, 255, 127));
}
//Put source image-resource into array
$ps['source_image'] = $source_image;
}
...BUT when I use imageflip ( http://php.net/manual/en/function.imageflip.php )
foreach($products_settings as &$ps) {
$filename = $_SERVER['DOCUMENT_ROOT'] . $ps['product_file'];
$source_image = imagecreatefromjpeg($filename);
imageflip($source_image, IMG_FLIP_BOTH); //code execution stops here
//Put source image-resource into array
$ps['source_image'] = $source_image;
}
then the imageflip()
makes the code stop (If I add log message the row after it doesn't log). I can't figure out WHY? What would be the reason for that? I can't see anything in errorlogs in codeigniter/php/apache. The manual says that the function will return false when fail, but I know the image is correct because I'm using other gd function for the same image with other gd-functions (as imagerotate
, imageColorAllocateAlpha
etc)
I've also tried this:
try {
imageflip($source_image, IMG_FLIP_BOTH);
}
catch (Exception $e) {
log_message('DEBUG', 'img err' . $e->__toString());
}
But nothings get logged...
How to debug this?