是否有任何开源 PHP 类可以将图像大小调整为特定的宽度和高度?
我目前有一个很简单的方法,可以通过纵横比来实现,但是我需要它来填充 150 x 150 的尺寸,而我的会遵循其比例并执行 150 x 120 的尺寸。
理想情况下,它会到达图像的中心。
谢谢
I have one currently that simple does it by aspect ratio, however I need it to fill a 150 x 150 size, whereas mine would honour its ratio and do 150 x 120 for example.
Ideally it would goto the centre of the image.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
虽然我认为 haim 提供的链接非常好用,但您可能需要考虑使用 ImageMagick,这是一款支持多语言的软件,我个人认为许多托管公司都有。我认为这是实现您正在寻找的内容的更有效方法,而不是使用 GD 库调整大小/裁剪。
看看这个内置函数。它还允许缓存并将远程图像复制到您的服务器。
While I think haim's offered link is very good to use, you may want to consider using ImageMagick, which is a multi-language-supported software that I personally believe many hosting companies have. I think it's a more efficient way of implementing what you're looking for, rather than resizing/cropping with GD library.
Take a look at this built function. It also allows caching, and copying remote images to your server.
我推荐了这个
简单的类,您可以调整大小/裁剪/翻转....
链接:
http://www.mawhorter.net/web-development/simple-image-manipulation-in-php-rotate-resize-裁剪翻转和镜像缩略图方形和常规
i recommended about this
simple class , you can resize / crop / flip ....
link :
http://www.mawhorter.net/web-development/simple-image-manipulation-in-php-rotate-resize-crop-flip-and-mirror-thumbnails-square-and-regular
有一个用于图像处理的 php 库,称为 GD - http://php.net/manual/ en/book.image.php
你可以看一下
There's a php library for image manipulation called GD - http://php.net/manual/en/book.image.php
You could give it a look
尝试使用 TimThumb,这是最流行的用于调整图像大小的 PHP 类
http://code.google.com/p/timthumb /
Try TimThumb, the most popular php class for image resizing
http://code.google.com/p/timthumb/