mynzhassar
(Marlen 777)
January 23, 2015, 10:22am
1
Hello,
I have faced following problem. When i upload a picture via mobile it gets saved with wrong orientation.
After searching, I found that it is possible to check for an image orientation before saving it.
To do it, it is required to read exif data of an image.
Could someone suggest me how could I do it in Yii2.
These are the steps I do to save file:
$uploadedFile = UploadedFile::getInstance($picture, 'picture_url');
$rnd = rand(0, 99999999);
$fileName = "{$rnd}-{$uploadedFile}";
$model->picture_url = $fileName;
$uploadedFile->saveAs(Yii::getAlias('@frontend') . '/web/uploads/' . $model->picture_url);
$model->save();
rwz
(Rz)
January 23, 2015, 1:15pm
2
I would look into the gd or imagick php extensions. They both have functions to auto rotate based on exif data. If you have Imagemagick installed on your server you can also use exec() to rotate the image with a command similar to
exec(‘mogrify -auto-orient /path/to/image.jpg’);
mynzhassar
(Marlen 777)
January 26, 2015, 3:55am
3
I would look into the gd or imagick php extensions. They both have functions to auto rotate based on exif data. If you have Imagemagick installed on your server you can also use exec() to rotate the image with a command similar to
exec(‘mogrify -auto-orient /path/to/image.jpg’);
Thanks for you answer,
I did some work with php. And it works perfectly fine. However, there are some problems with png extensions.
Any chance that there exist some yii2 extension that work with image manipulation, including auto-rotate based on orientation.
I have searched for it, but didn’t found anything that suits me.
Th3An1m4l
(Zverushka)
February 3, 2015, 2:57pm
4
Hi!
Could you please show your solution. Stuck with same issue on image rotation based on exif.
Using Yii2, Imagine
Thanks!
mynzhassar
(Marlen 777)
February 4, 2015, 4:44am
5
I have tried this extension. It is pretty good, solved my problem