怎么在php中使用imagick实现一个生成缩略图功能
本篇文章给大家分享的是有关怎么在php中使用imagick实现一个生成缩略图功能,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
<?php //缩略图 $tmpFile ='https://cache..com/upload/information/20201209/266/39900.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); } } ?>
以上就是怎么在php中使用imagick实现一个生成缩略图功能,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。