Re: [GD-DEVEL] Advanced image resize

[email protected] ("Pierre Joye") Tue, 10 Jun 2008 19:47:58 +0200
Newsgroups php.gd.devel
Message-ID <[email protected]>
On Tue, Jun 10, 2008 at 6:58 PM, ShadowRoze <[email protected]> wrote:

> I load the following types with the script utilizing the function: jpeg,
> gif, png.
> Not using ImageColorsForIndex results in having to use bitshifting instead.

Which is faster than calling the function and access the array table elements.

> After trying to implement all your suggestions the time required increased
> with 50% (ergo, to 30s).

I was not clear or you did something wrong (see below). I'm also not
sure why you copy the images twice (except if you want to copy it over
itself), filling it neither.

If you like to have a specific color (or translucent) for the
uncovered area, you can use imagefilledrectangle and only with the
desired area(s). It will also spare you some cycles (flood fill is
slow).

> Guess I'll have to wait for that one then.

Well, as I said, you are missing the main goal of  this algorithm. To
use bicubic for reducing the size of an image is completely useless
(be in C, php or whatever else).

I also wonder why you don't use imagecopyresampled.

Now about the possible optimization of your scripts, using only
truecolor images and the other things I listed earlier:

(in second)
ImageCopyResampledBicubic: 1.76
ImageCopyResampledBicubic2: 21.46
ImageCopyResampledBicubic: 31.84

The sources image is 3072x2034 and resized to 550x275.

Results can be seen here:

http://pierre.libgd.org/resize/

I don't see any relevant differences, nothing than can justify a PHP
implementation.

I'm pretty sure to drastically reduce these numbers by using a simpler
algorithm without visible impact.

If you load a png, verify if the image is truecolor, if not you can
use your version, if not it is fine to use Bicubic2.


Cheers,
--
Pierre

http://blog.thepimp.net | http://www.libgd.org