2012-03-09 4 views

답변

2

먼저 다른 서버에서 이미지를 가져와야합니다.이 경우 file_get_contents()을 사용할 수 있습니다.

그런 다음 이미지의 크기를 조정하려면 코드가 필요합니다. 그런 다음 현재 크기를 얻을 수 getimagesizefromstring()를 사용하여 원래의 상대를 아래로 크기를 조정할 경우 간단히, curl and resize remote image

: 당신이 아니라 로컬 파일보다 캐릭터의 이미지 내용을 가지고 있기 때문에, 당신은 imagecreatefromstring() 여기에 시도 사용할 수 있습니다 선택한 비율에 따라 새 크기를 계산하십시오.

$content = file_get_contents('http://site.com/image.jpg'); 

$originalSize = getimagesizefromstring($content); 

$originalWidth = $originalSize[0]; 
$originalheight = $originalSize[1]; 

$newSize = 0.6; // 60% of the original size 

$newWidth = $originalWidth * $newSize; 
$newHeight = $originalHeight * $newSize; 

// now you know what the resized width and height should be, you can go ahead and do the actual resizing 
+0

-하지만 난 그것을 포함하는 대답을 편집했습니다 .. 그것은 SHLD 원본 이미지에 상대적 .. 나의 끝에서 크기를 수정하려는 – Hacker

+0

@Hacker 해달라고. – MrCode

관련 문제