2013-12-20 2 views
2

jpeg 이미지를 검정색 & 흰색 (회색 음영)으로 변환하려고합니다. IMG_FILTER_GRAYSCALE. 잘 작동하지만 이미지를 폴더에 저장하고 싶습니다. 이 화면에 이미지 승 B &를 인쇄하고 난 내 브라우저에서 볼하지만 난 해요 이런 식으로 결국PHP - 변환 된 이미지를 폴더에 저장하십시오.

$im = imagecreatefromjpeg('pathtomyimage/myimage.jpg'); 
if($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) { 
header('Content-Type: image/jpeg'); 
imagejpeg($im); 
} else 
print 'Error during the b & w conversion'; 

매우 간단한 ...

: 코드 아래

폴더에 저장할 수 없습니다 (예 : img/bw/myimage.jpg).

할 수있는 방법이 있습니까? 내가 어떻게 해? the manual에서

답변

2

:

imagejpeg($im, 'img/bw/myimage.jpg'); 
+0

가 너무 간단 유능한! 감사합니다. :) :) –

0

당신은 당신은 폴더에 이미지를 저장하기 위해이 방법으로 imagejpeg 사용할 수있는이

$tmp=imagecreatetruecolor($newwidth,$newheight); 

    $newwidth1=120; 
    $newheight1=150; 
    $tmp1=imagecreatetruecolor($newwidth1,$newheight1); 

    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, 
    $width,$height); 

    imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1, 
    $width,$height); 

    $filename = "../Advertisement/". $_FILES['img']['name']; 
    $filename1 = "../Advertisement/small". $_FILES['img']['name']; 

    $filename2 = $_FILES['img']['name']; 
    imagejpeg($tmp,$filename,100); 
    imagejpeg($tmp1,$filename1,100); 

    imagedestroy($src); 
    imagedestroy($tmp); 
    imagedestroy($tmp1); 
0

처럼 사용할 수 있도록

imagejpeg($image, "/path/to/store/file.jpg");