◯ CakePHP3 ImageMagickでExifのOrientation情報あったら写真回転する方法(JPEGのみ)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // Exif Orientation変更(jpegのみ) // Orientation x(2-8) -> 1 ex) 水平反転 -> 通常 // 画像パス $photo_file_path = '画像パス'; // Exif取得 $exif_data = @exif_read_data($photo_file_path); // ExifのOrientation情報あったら写真回転 x(2-8) -> 1 if (isset($exif_data['Orientation']) && ($exif_data['Orientation'] != '1')) { if (system('/usr/bin/convert -auto-orient "'.$photo_file_path.'" -quality 80 "'.$photo_file_path.'"') === FALSE) { // 写真回転失敗 } else { // 写真回転成功 } } |