简体   繁体   English

在PHP S3上传时生成缩略图

[英]Generate Thumbnail On PHP S3 Upload

I have a PHP app that uploads an image. 我有一个上传图像的PHP应用程序。 I am using the S3 PHP Class (http://undesigned.org.za/2007/10/22/amazon-s3-php-class) 我正在使用S3 PHP类(http://undesigned.org.za/2007/10/22/amazon-s3-php-class)

Is it possible to create a smaller thumbnail and upload it to S3 as well? 是否可以创建一个较小的缩略图并将其上传到S3? I searched the web, but could not find anything. 我在网上搜索,但找不到任何东西。

Thanks 谢谢

Yes its possible, there are loads of libraries that will resize images for you. 是的,它有可能,有大量的库可以为您调整图像大小。

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

When you've resized the image just upload it in the same way. 当您调整图像大小时,只需以相同方式上传图像即可。

Once the file is uploaded to your server, you can do whatever you want with it. 将文件上传到服务器后,您可以随意执行任何操作。 PHP will provide you with the temporary location of the uploaded file in the variable $_FILES['your_form_element_name']['tmp_name'] PHP将在变量$_FILES['your_form_element_name']['tmp_name']为您提供上传文件的临时位置

From there you can use Imagick to resize the file, and then upload the resized image to S3 alongside your original image. 从那里,您可以使用Imagick调整文件大小,然后将调整大小的图像与原始图像一起上传到S3。

Imagick has a Imagick::thumbnailImage() method which is really easy to use. Imagick有一个非常容易使用的Imagick::thumbnailImage()方法。

More details on PHP file uploads here: http://www.php.net/manual/en/features.file-upload.post-method.php And more info about how to use Imagick here: http://php.net/manual/en/book.imagick.php 有关PHP文件上传的更多详细信息,请访问: http ://www.php.net/manual/en/features.file-upload.post-method.php以及有关如何使用Imagick的更多信息: http ://php.net /manual/en/book.imagick.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM