나는 내 자신의 질문에 대답 할 수 있었고 PHP 코드 스 니펫을 포함 시켰습니다.
유일한 단점은 적어도 부분 크기 이미지를 getImageSize
크기로 읽으려면 부분 이미지 다운로드를 파일 시스템에 쓰는 것입니다.
나를 위해 바이트는 200 ~ 400K 크기의 jpg 이미지를 확인하기위한 안전 한도입니다.
function remoteImage($url){
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_RANGE, "0-10240");
$fn = "partial.jpg";
$raw = curl_exec($ch);
$result = array();
if(file_exists($fn)){
unlink($fn);
}
if ($raw !== false) {
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status == 200 || $status == 206) {
$result["w"] = 0;
$result["h"] = 0;
$fp = fopen($fn, 'x');
fwrite($fp, $raw);
fclose($fp);
$size = getImageSize($fn);
if ($size===false) {
// Cannot get file size information
} else {
// Return width and height
list($result["w"], $result["h"]) = $size;
}
}
}
curl_close ($ch);
return $result;
}
당신은 무엇을 시도? JPEG 파일 형식에 대한 이해는 무엇입니까? http : //en.wikipedia에서 함께 만들 수있는 것을보십시오.org/wiki/Exchangeable_image_file_format # 예제 – tripleee
처음 4096 바이트에서 읽으 려했지만 Imagemagick 'identify'또는 'grep -n $ \ xc0'(참조 된 질문/설명 참조)을 실행하기 위해 찾지 못했습니다. – donohoe