【发布时间】:2012-01-30 22:39:26
【问题描述】:
我需要一些帮助。我对 cURL 很陌生。我得到了一个可以从 wordpress 博客(使用 magpie XML 解析器)创建提要的脚本。我还得到了一个图像调整大小脚本来为我调整图像大小。它可以在本地工作,但是因为我的网络托管禁用了 allow_url_fopen(),我被告知我需要使用 cURL,但我什么也做不了。
这是我尝试让 cURL 工作之前的代码:
<?php
$url = $_GET['imagesrc'];
// Set a maximum height and width
$width = 200;
$height = 200;
// Content type
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($url);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($url);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
header('Content-Type: image/jpeg');
return(imagejpeg($image_p, null, 100));
?>
【问题讨论】:
标签: php curl feed image-resizing