이미지가 PNG, GIF, TIFF 및 JPG인지 확인하고 축소 이미지를 만든 다음 엄지 파일에 저장하려면 어떻게해야합니까?PHP를 사용하여 이미지 확장을 확인하고 보는 방법은 무엇입니까?
지금까지 JPEG 이미지를 확인하고 저장할 수 있습니다.
다음은 아래 코드입니다.
<?php
//Name you want to save your file as
$save = 'members/3/images/thumbs/thumb-pic.jpg';
$file = 'members/3/images/pic.jpg';
echo "Creating file: $save";
list($width, $height) = getimagesize($file) ;
if ($width >= 180){
$modwidth = 180;
$modheight = ((180.0/$width) * $height);
} else {
$modwidth = $width;
$modheight = $height;
}
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
// Here we are saving the .jpg, you can make this gif or png if you want
//the file name is set above, and the quality is set to 100%
imagejpeg($tn, $save, 100) ;
?>
내 코드에 어떻게 추가합니까? – ImAGe
미리보기를 생성하는 것만 큼 간단하게 imagick을 사용하는 것은 거의 스케치 적이 지요 ... 내가 간 적이있는 호스트가 많지 않습니다. – brianreavis