Hello, in my projects I have always used the imagine library to upload and resize images. In my last project a user reported an image that when uploading it and using the thumbnail method, it was rotated and remained rotated 180°.
Doing some research I realized that it is possible that the image is really inverted but that modern browsers and systems read the EXFI and display it correctly.
I also found that the imgine library uses GD2 by default, and that this connector is not able to understand the EXFI information, so I guess my solution is to use the imagick connector.
The function I am trying to implement is the following
use yii\imagine\Image;
use Imagine\Gd;
use Imagine\Image\Box;
use Imagine\Image\BoxInterface;
public function actionCreate(){
//There are others lines previusly
Image::$driver = [Image::DRIVER_IMAGICK];
$img_t = Image::getImagine()->open($ruta_imgs . $modelo_editar->tax_imagenfrontalizquierda);
$img_t_thumb = $img_t->thumbnail(new Box(265, 150));
$img_t_thumb_rotada = $this->revisa_rotacion($img_t_thumb);
}
protected function revisa_rotacion($imagen){
$orientation = $imagen->getImageOrientation();
switch ($orientation) {
case 8:
$imagen->rotateimage("#000", -90);
break;
case 3:
$imagen->rotateimage("#000", 180);
break;
case 6:
$imagen->rotateimage("#000", 90);
break;
}
return $imagen;
}
but i get the following error.
Call to undefined method Imagine\Imagick\Image::getImageOrientation()
Can you help me, please?