2012-02-10 5 views
0
$row = mysql_fetch_array($result); 
$src1 = $row['file_name']; 
$targ_w = $targ_h = 350; 
$jpeg_quality = 90; 
$img_r = imagecreatefromjpeg($src1); 
$dst_r = ImageCreateTrueColor($targ_w, $targ_h); 

imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'], 
$targ_w,$targ_h,$_POST['w'],$_POST['h']); 

header('Content-type: image/jpg'); 
imagejpeg($dst_r,null,$jpeg_quality); 

이 예제의 파일 저장 방법은 어떻게됩니까? 이것은 소스 파일 이름입니다. $ src1 = $ row [ 'file_name']; 파일을 미리 볼 수만 있지만 저장할 수는 없습니다.자른 파일 저장

답변

2

두 번째 매개 변수는 경로를 저장합니다.

imagejpeg($dst_r, $src1,$jpeg_quality); 
+0

@minitech $ src1은 초기 파일 이름이고 자른 파일은 다른 파일 이름을 원합니다. 파일의 대상을 어떻게 포함해야합니까? – apple

+0

@apple : 원하는 경로를 선택할 수 있습니다. 거기에 $ src1을 유지하면 오래된 이미지가 잘린 것으로 바뀝니다 –

+0

어떻게 경로를 선택해야합니까? $ dst_r입니까? imagejpeg ($ dst_r, null, $ jpeg_quality)에서 코드를 변경할 때; to imagejpeg ($ dst_r, $ src1, $ jpeg_quality); 오류 메시지가 나타납니다. – apple

관련 문제