php在新浪云中使用imagick的方法

来源:文书网 2.36W

imagick是一款php的`图像处理插件了我们可以使用imagick来进行许多的一些操作了,下面我们来看一篇关于php在新浪云中使用imagick的方法,具体的细节如下:

php在新浪云中使用imagick的方法

php在新浪云中使用imagick生成缩略图并上传到Storage的方法:

<?php

//缩略图

$tmpFile ='http://phpff.com/original.jpg' ;

list($width, $height) = getimagesize($tmpFile);

// resize if necessary

if ($width >= 550 && $height >= 550) {

$image = new Imagick($tmpFile);

$image->thumbnailImage(550, 550,true);

/* 上传文件到Storage */

$st = new SaeStorage();

$tmp_url = SAE_TMP_PATH.time();//保存到sae临时目录

file_put_contents($tmp_url,$image);

$path='/201608/22/1471856203_98548400.jpg';

if (!$st->upload('upload', $path, $tmp_url)) {

echo 0;

} else {

echo $st->getUrl('upload', $path);

}

}

?>

热门标签