I'm using blueimp upload widget to upload images to my file server, which works fine.
The only issue is that, I want to rotate the image correctly before I upload it to server, so when I link to it through a URL it displays in the right orientation.
Any idea on which setting to use?
Maybe you need another plugin, like https://fengyuanchen.github.io/cropper/
preview image rotate, then crop image
This is a backend solution. We dont allow tiff image uploads, so I didnt include the image type check.
$uploadedFile->tempName is the file path eg: "/var/www/site/upload/images/someImage.jpg"
if(exif_imagetype($uploadedFile->tempName) == 2)//2 IMAGETYPE_JPEG
{
$exif = exif_read_data($uploadedFile->tempName);
if(!empty($exif['Orientation']))
{
$image = imagecreatefromjpeg($uploadedFile->tempName);
switch($exif['Orientation'])
{
case 8:
$image = imagerotate($image,90,0);
break;
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
}
imagejpeg($image, $uploadedFile->tempName);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With