Home  |  Linux  | Mysql  | PHP  | XML
From:Pierre Joye Date:Tue Jun 10 10:23:50 2008
Subject:Re: [GD-DEVEL] Advanced image resize
hi,

On Tue, Jun 10, 2008 at 6:04 PM, ShadowRoze <roze@laun.se> wrote:
> Hi, I would like to request that you add binary support for running Bicubic
> image resizing. Currently I only have a PHP code snippet, taking approx 20
> seconds to resize a 2000x1000px image to 550x275px.

For scaling images, is it really better than imagecopyresampled?

> I would like you to try speeding up this function, since 20 seconds is quite
> much, and the current functions does look quite bad.

> http://pastebin.com/m216c7c32   <-- the function I'm using.

A couple of things that may help to speed up a bit your script:
- if you load jpeg, drop the imagecolorforindex alltogether, jpeg are
always truecolor (create two loops)
- don't allocate the color, simply calculate it once and use it with
setpixel (0xAARRGGBB where AA goes from 0..127, other 0..255) save w*h
function calls
- truecolor image has no palette, no need to copy it (save a function call)
-  calculate ($w - $ow) (and its $h equivalent) outside the loops, php
does not optimize this part

And more generally, why don't you use a simpler algorithm for
stretching images? Bicubic is good for scaling images (> 1.0x) but is
not particullary good or fast for reducing images. A area weight
implementation is fast and can give almost the best result
(speed/quality ratio is good too).

About adding new interpolations (besides copyresampled), it is in
progress, I have working code already. The C API provides the
following methods (classic and a couple of optimized versions):

http://pierre.libgd.org/affine/api/files/src/gd-h.html#gdInterpolationMethod

I'm also planing to add MMX/SSE2 version as well. These new features
should be in php 5.3.

Cheers,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org
Navigate in group php.gd.devel at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants