X-Git-Url: https://git.jacobcasper.com/?p=pics.git;a=blobdiff_plain;f=upload.php;fp=upload.php;h=65edac0b96176a08eb8d8356afc172ef6fcb68aa;hp=d69e283ae618bb6718f5149c0fe3a3525a906721;hb=f58582b2be1e449e84f5a45f9560854d3c9076e6;hpb=cab93e4b4b26611d59bee711f221e88f4d392dc2 diff --git a/upload.php b/upload.php index d69e283..65edac0 100644 --- a/upload.php +++ b/upload.php @@ -22,12 +22,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { die('Upload error'); } $size = $images['size'][$i]; - // strip EXIF + + // imagemagick manip code $img = new Imagick($tmp_file); - // keep ICC for quality + // no compression + $img->setImageCompressionQuality(100); $profiles = $img->getImageProfiles("icc", true); + $exif_orientation = $img->getImageOrientation(); + + // STRIP EXIF DATA $img->stripImage(); + + // REAPPLY EXIF DATA + if($exif_orientation === imagick::ORIENTATION_BOTTOMRIGHT) { + $img->rotateImage("#000", 180); + } elseif ($exif_orientation === imagick::ORIENTATION_RIGHTTOP) { + $img->rotateImage("#000", 90); + } elseif ($exif_orientation === imagick::ORIENTATION_LEFTBOTTOM) { + $img->rotateImage("#000", -90); + } + $img->setImageOrientation(imagick::ORIENTATION_TOPLEFT); if(!empty($profiles)) { + // keep ICC for quality $img->profileImage('icc', $profiles['icc']); }