PHP - EXIF Error con dispositivos IOS | Ayuda

 
Vista:
sin imagen de perfil

EXIF Error con dispositivos IOS | Ayuda

Publicado por Alejandro (1 intervención) el 13/04/2018 16:46:14
Buenas a todos, abro esta cadena debido a que estoy teniendo problemas al subir fotos a mi admin de contenidos de la página. Con las imágenes de otros dispositivos no tengo problema debido a que estos no ocultan la EXIF pero con dispositivos de IOS tengo el problema de que se me gira la imagen 90 grados a la izquierda.

Este es el código que tengo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
protected function gd_orient_image($file_path, $src_img) {
    if (!function_exists('exif_read_data')) {
        return false;
    }
    $exif = @exif_read_data($file_path);
 
    if ($exif === false) {
        return false;
 
    }
 
    $orientation = (int)@$exif['Orientation'];
    if ($orientation < 2 || $orientation > 8) {
        return false;
    }
    switch ($orientation) {
        case 2:
            $new_img = $this->gd_imageflip(
                $src_img,
                defined('IMG_FLIP_VERTICAL') ? IMG_FLIP_VERTICAL : 2
            );
            break;
        case 3:
            $new_img = imagerotate($src_img, 180, 0);
            break;
        case 4:
            $new_img = $this->gd_imageflip(
                $src_img,
                defined('IMG_FLIP_HORIZONTAL') ? IMG_FLIP_HORIZONTAL : 1
            );
            break;
        case 5:
            $tmp_img = $this->gd_imageflip(
                $src_img,
                defined('IMG_FLIP_HORIZONTAL') ? IMG_FLIP_HORIZONTAL : 1
            );
            $new_img = imagerotate($tmp_img, 270, 0);
            imagedestroy($tmp_img);
            break;
        case 6:
            $new_img = imagerotate($src_img, -90, -1);
            break;
        case 7:
            $tmp_img = $this->gd_imageflip(
                $src_img,
                defined('IMG_FLIP_VERTICAL') ? IMG_FLIP_VERTICAL : 2
            );
            $new_img = imagerotate($tmp_img, 270, 0);
            imagedestroy($tmp_img);
            break;
        case 8:
            $new_img = imagerotate($src_img, 90, 0);
            break;
        default:
            return false;
    }
 
    $this->gd_set_image_object($file_path, $new_img);
    return true;
}
Desde ya gracias a los que quieran contribuir en este tema y aclarar dudas
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder