-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image flip bug wrong parameter #1
Comments
Thanks for reporting this. Strange that I will look into it for next release. Thanks for reporting! PS! I have a short working version of this in the files.gallery application. function exif_orientation($orientation, &$image){
if(empty($orientation) || !is_numeric($orientation) || $orientation < 3 || $orientation > 8) return;
$image = imagerotate($image, array(6 => 270, 5 => 270, 3 => 180, 4 => 180, 8 => 90, 7 => 90)[$orientation], 0);
if(in_array($orientation, array(5, 4, 7)) && function_exists('imageflip')) imageflip($image, IMG_FLIP_HORIZONTAL);
return true;
} |
I see that. How about something like this code: function fix_orientation ($orientation, $fileandpath, $ext, $quality=80) { // Gets the GD image resource for loaded image // If it failed to load a resource, give up
} if (!$ret) { // If theres no final image resource to output for whatever reason, give up |
the last code I posted is tested against a set of images in different orientations. It passes. The code from files.gallery also has a bug with case 2 and 4. Here's a fixed version: function exif_orientation ($orientation = -1, &$image = null) { if (empty ($orientation) || !is_numeric ($orientation)) { // bad input // lets rotate first // do we need to flip it |
I can't see any bugs there. As you can see, the Anyway, thanks for reporting this and making suggestions. I will definitely have it resolved for next X3 release. |
Here's the test set. |
I see the images in your test set, are the same images that I have in our Files Gallery demo: All the resized images (thumbnails) have been oriented from the code posted, and as you can see, it's definitely working as it should. |
There is a bug in this routine: fix_orientation
The call to imageflip returns a boolean, not a flipped image. The fixed routine is like this:
function fix_orientation ($orientation, $fileandpath, $ext, $quality=80) {
// Gets the GD image resource for loaded image
$img_res = get_image_resource ($fileandpath, $ext);
// If it failed to load a resource, give up
if (is_null ($img_res)) {
return false;
}
// auto rotate
switch ($orientation) {
}
// If theres no final image resource to output for whatever reason, give up
if (!isset ($ret)) {
return false;
}
// save image
save_image_resource ($img_res, $fileandpath, $ext, $quality);
// Free up memory
imagedestroy ($img_res);
}
The text was updated successfully, but these errors were encountered: