I am working on a project that resizes images using PHP's GD library. I would like to be able to add the option to use seam carving to resize images but don't want to require something like ImageMagick (which can do seam carving with its liquid rescale feature) to accomplish this.
我正在开发一个使用PHP的GD库调整图像大小的项目。我希望能够添加选项以使用接缝雕刻来调整图像大小,但不希望像ImageMagick(可以使用其液体重新缩放功能进行接缝雕刻)来完成此操作。
Since there are no built-in seam carving functions in GD, is there a way to perform seam carving on an image using PHP's GD library or other built-in PHP functions? Alternatively, do you know if seam carving will eventually be baked into GD?
由于GD中没有内置的接缝雕刻功能,有没有办法使用PHP的GD库或其他内置的PHP函数在图像上进行接缝雕刻?或者,你知道缝线雕刻最终会被烘焙到GD吗?
2 个解决方案
#1
2
While you could implement this using GD, you're best bet if you can control the server environment is to create an external script/program to carve an image. PHP is going to be a huge bottleneck doing those kind of calculations. Even basic matrix transformations run a serious risk of hitting the max execution times set in PHP configs.
虽然您可以使用GD实现此功能,但您最好选择控制服务器环境是创建外部脚本/程序来雕刻图像。 PHP将成为进行这些计算的巨大瓶颈。即使是基本的矩阵转换也存在着达到PHP配置中设置的最大执行时间的严重风险。
#2
0
I don't see why it shouldn't be possible with GD, but I can tell you it would be slow.
我不明白为什么用GD不可能,但我可以告诉你它会很慢。
Imagemagick is open source, so I guess you could translate the function to PHP.
Imagemagick是开源的,所以我猜你可以把这个函数翻译成PHP。
#1
2
While you could implement this using GD, you're best bet if you can control the server environment is to create an external script/program to carve an image. PHP is going to be a huge bottleneck doing those kind of calculations. Even basic matrix transformations run a serious risk of hitting the max execution times set in PHP configs.
虽然您可以使用GD实现此功能,但您最好选择控制服务器环境是创建外部脚本/程序来雕刻图像。 PHP将成为进行这些计算的巨大瓶颈。即使是基本的矩阵转换也存在着达到PHP配置中设置的最大执行时间的严重风险。
#2
0
I don't see why it shouldn't be possible with GD, but I can tell you it would be slow.
我不明白为什么用GD不可能,但我可以告诉你它会很慢。
Imagemagick is open source, so I guess you could translate the function to PHP.
Imagemagick是开源的,所以我猜你可以把这个函数翻译成PHP。