我有一个脚本可以获取RSS提要,但有些图片更大,占用的空间太大。如何调整图像大小我尝试过这个课程但没有成功:
https://github.com/Nimrod007/PHP_image_resize
我已加入并致电该功能
这是来自脚本的代码:
if (!empty($image)) {
/*here's the calling resize function*/
smart_resize_image(null , file_get_contents($image), 300, 300, false , $resizedFile , false , false ,100 );
$filetype = strtolower(substr(strrchr($resizedFile,'.'),1));
if (!in_array($filetype,array('jpg','jpeg','png','gif'))) {
$filename = '';
} else {
$filename = 'image_'.time().'_'.rand(0000000,99999999).'.'.$filetype;
$up = file_put_contents('../uploads/newss/'.$filename,file_get_contents($resizedFile));
$size = filesize('../uploads/newss/'.$filename);
list($width) = getimagesize('../upload/news/'.$filename);
if(intval($size) >= 1024 AND $width >= 40) {
$filename = $filename;
} else {
unlink('../uploads/newss/'.$filename);
$filename = '';
}
}
} else {
$filename = '';
}