需要 PHP 图像调整器/裁剪脚本
我正在抓取图像链接,需要将其即时转换为 72x108 以在网站上显示。源图像来自各种分辨率,因此需要裁剪。
我知道 PHP 的中等水平,所以我可能可以做一些满足我需要的东西,但希望有一些可以通过 url 请求调用的东西。 EG:mysite.com/thumbnail.php?src=http://anothersite.com/image.jpg&w=72&h=108
这将是理想的,它需要支持jpg/png。
提前致谢!
I am grabbing links to images and need to convert them on the fly to 72x108 to display on a website. The source images come from various resolutions, so cropping is required.
I know a moderate level of PHP so I can probably make something work for my needs, but was hoping for something that could be called by a url request. EG: mysite.com/thumbnail.php?src=http://anothersite.com/image.jpg&w=72&h=108
That would be ideal, it needs to support jpg/png.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个非常方便的脚本,用于处理和上传图像,它永远是谷歌搜索结果的顶部。我几年前就用过它,它非常容易实现。看起来它也是几周前才更新的:)
http://www.verot.net/php_class_upload。 htm
这可能有点过分了,但是如果您查看示例,您会发现可以用它做很多事情。如果您不在本项目中使用它,那么在下一个项目中尝试一下可能是值得的。
Here is a really handy script for processing and uploading images that's been a top google result for forever. I used it years ago and it was really easy to implement. Looks like it was just updated a couple weeks ago too :)
http://www.verot.net/php_class_upload.htm
This may be overkill, but if you check out the examples you can see there's a lot you can do with it. If you don't use it for this project, it might be worthwhile to try out for the next one.
只需使用 file_get_contents 或使用 curl 从 url 读取图像,然后使用 php gd 库根据您的需要调整图像大小和裁剪图像。
请访问以下链接以获取更多信息:
http://php.net/ Manual/en/function.file-get-contents.php
http:// php.net/manual/en/book.image.php
http:// davidwalsh.name/download-urls-content-php-curl
just read the image from the url with file_get_contents or using curl and use the php gd library to resize and crop the image as per your needs.
Go through the following links for more info:
http://php.net/manual/en/function.file-get-contents.php
http://php.net/manual/en/book.image.php
http://davidwalsh.name/download-urls-content-php-curl