我可以在將圖像發佈到imgur之前調整圖像大小?我已經測試鏈接像http://i.imgur.com/XXXXXl.png但我需要調整前CURL在上傳到Imgur之前調整圖像大小
foreach ($_FILES['file']['tmp_name'] as $index => $tmpName) {
if(!empty($tmpName) && is_uploaded_file($tmpName))
{
$file = base64_encode(file_get_contents($tmpName));
$pvars = array(
'image' => $file,
'type' => 'base64'
);
$timeout = 120;
$imgurClientID = "xxx";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $imgurClientID));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
$response = curl_exec($curl);
curl_close($curl);
$dataImg = json_decode($response, true);
$link = $dataImg['data']['link'];
}
}
感謝
感謝您的回覆,我誰可以使用imagick用的file_get_contents? '$ image = new Imagick($ tmpFile); $ image-> resizeImage(400,400); file_get_contents($ image)'? – soooo
檢查示例,$ imagick-> getImageBlob()返回轉換圖像的二進制bolb。 – xvan