åçã¢ãããã¼ãã®éã®ä¸åãããã¾ãåããªãããææ¦ãã¦ã¿ãã
åçã«ã¯ä¸åãä¸åãããWEBã«ã¡ã©ã®å ´åã¯å·¦å³å転ããããä¸å£ã«ãã¸ã«ã¡åçã¨ãã£ã¦ãæ§ã
ãªãã®ãããã
Windowsã®ãµã ãã¤ã«ã¯ã²ã©ãã
Windowsã®ãã¤ãã¯ãã£ã®ãµã ãã¤ã«ãèªåå転ããªããæåå転ãããã¨ãå£åããããã¨ãç¯ä»ãªè¦åãåºããGNOMEã®Nautilusã ã¨ãã¤ãã¯ãã£ã¯ãµã ãã¤ã«ãããã³ã¨è§£éãã¦ããããUbuntuã使ã£ã¦ã¦èªåè£æ£ããã¦é©ãããä¸ä¸ã®è£æ£ããã¦ããããåãåçãWindowsã¨nautilusã§ãã¬ãã¥ã¼ããã¨ãã«ããããªã¨éããåããã
EXIFæ å ±ãæ´»ç¨ããã
ãã¸ã«ã¡åçã«ã¯ãã¼ã¿ãåãè¾¼ã¾ãã¦ããï¼EXIFã¢ã¸ã¥ã¼ã«ã§è¦ãããï¼
ãã¸ã«ã¡ã«åãè¾¼ã¾ãã¦ãããåãæ
å ±ã¯ãOrientationãé
åã«å
¥ã£ã¦ããã
Orientationã®å転ãã¿ã¼ã³ã®å®ç¾©ã
Orientationã®å¤ã§ãåçãã¬ãã¥ã¼æã®å¦çãå®ç¾©ãã¦ããã
Exif-orientation-1:é常 Exif-orientation-2:å·¦å³å転 Exif-orientation-3:180°å転 Exif-orientation-4:ä¸ä¸å転 Exif-orientation-5:åæè¨åãã«90°å転 ä¸ä¸å転 Exif-orientation-6:æè¨åãã«90°å転 Exif-orientation-7:æè¨åãã«90°å転 ä¸ä¸å転 Exif-orientation-8:åæè¨åãã«90°å転
æ¹åãä¿®æ£ããé¢æ°ã
ãããå ã«ãPHPã§åããä¿®æ£ããé¢æ°ãä½ã£ã¦ã¿ãã
<?php public function make_orientation_fixed_blob($raw) { $img = new Imagick(); $ver = $img->getVersion(); $img->readImageBlob($raw); $orientation = 0; if( method_exists($img, "getImageOrientation") ){ $orientation = $img->getImageOrientation(); } if(!$orientation && function_exists("read_exif_data")){ $exif = read_exif_data($this->image_path("original").DIRECTORY_SEPARATOR.$this->file_name()); $orientation = $exif['Orientation']; } switch((int)$orientation) { case 0:#æªå®ç¾© break; case 1:#é常 break; case 2:#å·¦å³å転 $img->flopImage(); break; case 3:#180°å転 $img->rotateImage(new ImagickPixel(), 180 ); break; case 4:#ä¸ä¸å転 $img->flipImage(); break; case 5:#åæè¨åãã«90°å転 ä¸ä¸å転 $img->rotateImage(new ImagickPixel(), 270 ); $img->flipImage(); break; case 6:#æè¨åãã«90°å転 $img->rotateImage(new ImagickPixel(), 90 ); break; case 7:#æè¨åãã«90°å転 ä¸ä¸å転 $img->rotateImage(new ImagickPixel(), 90 ); $img->flipImage(); break; case 8:#åæè¨åãã«90°å転 $img->rotateImage(new ImagickPixel(), 270 ); break; } $raw = $img->getImageBlob(); unset($img); return $raw; }
åä½ã«å¿ è¦ãªã¢ã¸ã¥ã¼ã«ã¯ImageMagick/Exifã
ImageMagickã®ã¤ã³ã¹ãã¼ã«ã®ç¢ºèª
$> php -r '$img = new Imagick();print_r($img->getVersion());'
ImageMagickã¯ããã©ã«ãã¤ã³ã¹ãã¼ã«ããã¦ããªããã¨ãå¤ããImageMagickãªãã¨ãã¯GDã使ãã°ããã
使ç¨ä¾ï¼åçã®åã調æ´ã¯æ¬¡ã«å ´æã®ä½¿ç¨ãã¦ãã¾ãã
ãã¸ã«ã¡åçãã¢ãããã¼ãåºæ¥ãã¨æ¥½ãããªãã§ãåããæ£ãããªãã®ã§æããã£ãã
ã¨ãããã¨ã§ãç»åã¢ãããã¼ãã®éã«çµã¿è¾¼ãã§ãããã
å®éã«åä½ããã¦ã¿ã¦ç¹ã«åé¡ã¯ããã¾ããã§ããã