From 9fbe921051adec1517e2ded8122033bc3d11ea85 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Sun, 8 Jul 2012 09:18:05 -0600 Subject: [PATCH 1/2] auto-orient uploaded wall photos and profile photos also --- include/Photo.php | 2 +- mod/photos.php | 3 +-- mod/profile_photo.php | 7 +++++++ mod/wall_upload.php | 7 +++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/Photo.php b/include/Photo.php index 3af1691ee7..f07019e714 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -143,7 +143,7 @@ class Photo { public function orient($filename) { // based off comment on http://php.net/manual/en/function.imagerotate.php - if(! function_exists('exif_read_data')) + if( (! function_exists('exif_read_data')) || ($this->getType() === 'image/png') ) return; $exif = exif_read_data($filename); diff --git a/mod/photos.php b/mod/photos.php index 42cad42f9c..624f0bdcaa 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -740,8 +740,7 @@ function photos_post(&$a) { killme(); } - if($ph->getType() != 'image/png') - $ph->orient($src); + $ph->orient($src); @unlink($src); $max_length = get_config('system','max_image_length'); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index e44707f9bb..67b2c4ab41 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -128,6 +128,7 @@ function profile_photo_post(&$a) { return; } + $ph->orient($src); @unlink($src); return profile_photo_crop_ui_head($a, $ph); @@ -237,6 +238,12 @@ function profile_photo_content(&$a) { if(! function_exists('_crop_ui_head')) { function profile_photo_crop_ui_head(&$a, $ph){ + $max_length = get_config('system','max_image_length'); + if(! $max_length) + $max_length = MAX_IMAGE_LENGTH; + if($max_length > 0) + $ph->scaleImage($max_length); + $width = $ph->getWidth(); $height = $ph->getHeight(); diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 5990f28344..07d97d17a9 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -101,8 +101,15 @@ function wall_upload_post(&$a) { killme(); } + $ph->orient($src); @unlink($src); + $max_length = get_config('system','max_image_length'); + if(! $max_length) + $max_length = MAX_IMAGE_LENGTH; + if($max_length > 0) + $ph->scaleImage($max_length); + $width = $ph->getWidth(); $height = $ph->getHeight(); From fb4295f07f6c4a98147936b4442d69d88989d720 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Sun, 8 Jul 2012 11:17:50 -0600 Subject: [PATCH 2/2] better check for image EXIF support --- include/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Photo.php b/include/Photo.php index f07019e714..ba4241a7b8 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -143,7 +143,7 @@ class Photo { public function orient($filename) { // based off comment on http://php.net/manual/en/function.imagerotate.php - if( (! function_exists('exif_read_data')) || ($this->getType() === 'image/png') ) + if( (! function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg') ) return; $exif = exif_read_data($filename);