views:

493

answers:

2

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.

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?

A: 

I don't see why it shouldn't be possible with GD, but I can tell you it would be slow.

Imagemagick is open source, so I guess you could translate the function to PHP.

Greg
+2  A: 

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.

dcousineau