如何使用PHP裁剪jpg图像?

时间:2016-11-21 17:52:14

标签: php image jpeg crop

使用ImageMagic可以使用下面的代码轻松完成裁剪,但是在托管服务器中安装ImageMagic是不可能的。那么有没有办法只用php做到这一点?需要裁剪 jpg图像而不是png。以及如何停止降低图像的质量?

d = [[datetime.datetime(2016, 11, 1, 0, 0), 50L],
[datetime.datetime(2016, 11, 2, 0, 0), 50L],
[datetime.datetime(2016, 11, 2, 0, 0), 50L],
[datetime.datetime(2016, 11, 2, 0, 0), 23L],
[datetime.datetime(2016, 11, 2, 0, 0), 23L],
[datetime.datetime(2016, 11, 2, 0, 0), 23L],
[datetime.datetime(2016, 11, 7, 0, 0), 23L],
[datetime.datetime(2016, 11, 8, 0, 0), 23L],
[datetime.datetime(2016, 11, 9, 0, 0), 23L],
[datetime.datetime(2016, 11, 9, 0, 0), 23L],
[datetime.datetime(2016, 11, 9, 0, 0), 66L],
[datetime.datetime(2016, 11, 9, 0, 0), 66L],
[datetime.datetime(2016, 11, 13, 0, 0), 50L],
[datetime.datetime(2016, 11, 14, 0, 0), 50L],
[datetime.datetime(2016, 11, 15, 0, 0), 100L],
[datetime.datetime(2016, 11, 16, 0, 0), 100L],
[datetime.datetime(2016, 11, 17, 0, 0), 100L],
[datetime.datetime(2016, 11, 17, 0, 0), 100L],
[datetime.datetime(2016, 11, 17, 0, 0), 100L],
[datetime.datetime(2016, 11, 20, 0, 0), 100L],
[datetime.datetime(2016, 11, 21, 0, 0), 100L],
[datetime.datetime(2016, 11, 21, 0, 0), 100L],
[datetime.datetime(2016, 11, 23, 0, 0), 50L]]

1 个答案:

答案 0 :(得分:0)

以下是裁剪图像的一些替代方法:

使用composer package intervention\image

https://packagist.org/packages/intervention/image

使用图像处理作为cloudinary服务(它是强大且免费/廉价的简单图像处理和云存储):

http://cloudinary.com