1
디렉토리의 모든 이미지를 검사하고 너비를 확인하며이 너비가 맞지 않는 경우 작은 스크립트를 만들고 있습니다. -하지만이 스크립트가 실행되는 같은 디렉토리에 이미지 파일이 수정되지 않은 스크립트가 확인을 실행처럼디렉토리의 모든 이미지 크기를 조정하고 크기를 조절하십시오.
$files = glob("*.{png,jpg,jpeg}", GLOB_BRACE);
foreach ($files as $file)
{
// get the image size
$imagesize = getimagesize($file);
$width_orig = $imagesize[0];
$height_orig = $imagesize[1];
$dst_w = 900;
if($width_orig != $dst_w)
{
$dst_h_multiplier = $dst_w/$width_orig;
$dst_h = $dst_h_multiplier * $height_orig;
$dst = imagecreatetruecolor($dst_w, $dst_h);
$image = imagecreatefromjpeg($file);
imagecopyresampled($dst, $image, 0, 0, 0, 0, $dst_w, $dst_h ,$width_orig, $height_orig);
imagejpeg($dst,null,100);
}
}
그것은 것 같다 :
는 내가 지금까지 가지고하는 것은 이것이다.
무엇이 여기에 있습니까? 어떻게 디버깅 할 수 있습니까?
나는 봅니다. 그건 실제로 작동 -하지만 null을 전달하면 원래 파일을 덮어 쓸 줄 알았는데? – willdanceforfun
@cosmicbdog : 그는 어떤 파일 (그리고 어디서)이 원본 파일인지 알지 못합니다. $ dst에는 이미지 데이터가 포함되어 있습니다. – dynamic
설명해 주셔서 감사합니다. – willdanceforfun