Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rotate image before upload using blueimp upload

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?

like image 257
Birger Püschl Avatar asked Jun 29 '16 09:06

Birger Püschl


2 Answers

Maybe you need another plugin, like https://fengyuanchen.github.io/cropper/

preview image rotate, then crop image

like image 174
Raymond Cheng Avatar answered Nov 09 '22 07:11

Raymond Cheng


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);
}
}
like image 2
norcal johnny Avatar answered Nov 09 '22 09:11

norcal johnny