我正在使用php tp上传图片....我想知道
答案 0 :(得分:1)
答案 1 :(得分:1)
当我需要做同样的事情时,我一直在使用我找到的课程,到目前为止,只需要很少的修改就可以了。在这里:SimpleImage Class
<?php
include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->resize(250,400);
$image->save('picture2.jpg');
// and a lot more examples at the class website.
?>
如果这不符合您的需求,php手册有很多功能可以帮助您实现所需。 Image
答案 2 :(得分:0)
我创建了一个插件,可以生成具有质量和大小设置的缩略图以及剪切方法,可以缓存缩略图,使您可以在视图中的不同位置和大小使用相同的图像。
我相信这可以解决您的问题:
https://github.com/emersonsoares/ThumbnailsPlugin
用法:
echo $this->Thumbnail->render('test.jpg', array(
'width' => '100',
'height' => '100',
'resizeOption' => 'portrait',
'quality' => '100'
), array('id' => 'img-test', 'alt' => 'thumbnail test'));