rosell-dk / webp-convert

Convert jpeg/png to webp with PHP (if at all possible)
MIT License
578 stars 102 forks source link

Conversion become slow after converting 5000+ images #264

Closed AbdulSamadAbbasi closed 3 years ago

AbdulSamadAbbasi commented 3 years ago

I'm converting using gd, because looks like it's faster than other, at start it converts at a good pace but after converting 5000-6000 images it becomes much slow. What should I do to speed it up, or is it by default like this?

rosell-dk commented 3 years ago

Hi, sorry for not reacting to this before.

It sounds like memory leak. So looked the code over and yes: Under some circumstances, the image resource does not get destroyed. It can happen in the makeTrueColorUsingWorkaround() method, which is called when imagepalettetotruecolor() is unavailable. imagepalettetotruecolor is however available in PHP 5.5.0, so if this is the root of the problem, you are on a very old version of PHP. Also, the function is only called when the image needs color conversion

Btw: Conversion with gd is not very good, as it doesn't accept any webp options and it cannot convert to lossless. Only use gd if no other converters are working.

I will fix the memory leak

rosell-dk commented 3 years ago

Fixed the memory leak. Can you tell which version of Gd and PHP you were using?