Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ System requirements are:
* with [xmlwriter extension](https://www.php.net/manual/en/book.xmlwriter.php) enabled, to create DOCX files
* [GD library](https://www.php.net/manual/en/book.image.php) recommended, to manage the size of uploaded photos
* with [curl extension](https://www.php.net/manual/en/book.curl.php) enabled, if you intend to use the Mailchimp integration
* with [exif extension](https://www.php.net/manual/en/book.exif.php) enabled, if you would like to automatically rotate images

The steps to install are:
1. Unzip the files into a web-accessible folder on your web server
Expand Down
28 changes: 15 additions & 13 deletions include/photo_handler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ public static function getUploadedPhotoData($fieldName, $crop=NULL)
$fn = 'imagecreatefrom'.$ext;
$input_img = $fn($_FILES[$fieldName]['tmp_name']);
if (!$input_img) exit;
// Rotate the image as necessary - thanks https://www.php.net/manual/en/function.exif-read-data.php#110894
$exif = @exif_read_data($_FILES[$fieldName]['tmp_name']);
if (!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$input_img = imagerotate($input_img,90,0);
break;
case 3:
$input_img = imagerotate($input_img,180,0);
break;
case 6:
$input_img = imagerotate($input_img,-90,0);
break;
if (function_exists('exif_read_data')) {
// Rotate the image as necessary - thanks https://www.php.net/manual/en/function.exif-read-data.php#110894
$exif = @exif_read_data($_FILES[$fieldName]['tmp_name']);
if (!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$input_img = imagerotate($input_img,90,0);
break;
case 3:
$input_img = imagerotate($input_img,180,0);
break;
case 6:
$input_img = imagerotate($input_img,-90,0);
break;
}
}
}
$orig_width = imagesx($input_img);
Expand Down