Hi On Jun 17, 2016 8:18 PM, "Christoph Becker" <cmbecke...@gmx.de> wrote: > > Hi! > > I like to suggest to improve the current test suite of the gd extension. > The main issue I see with the current suite is that many (~ 28) tests > use md5() to verify that a drawn image is correct. However, as Pierre > mentioned long ago[1], md5() does not work (reliably) for this purpose. > > An alternative would be to have prepared images, and to compare these > with the actual resulting images pixel by pixel. While that might work > fine for lossless compression, it still can result in failing tests, > which would be hard to track down, and obviously a pure PHP > implementation is slow. > > Especially, when it comes to verify lossy image compression a more > sophisticated approach is required. Due to the necessity to test > imagewebp() I had committed a very simplistic calc_image_dissimilarity() > a while ago[2]. Obviously, this should be improved either regarding the > algorithm as well as the performance. > > libgd already has a much better testing library written in C[3], which > generates image diffs for failing tests, and we may consider to use > parts of it for PHP. I can't see any issues regarding the license. > > Thoughts?
The current testing code is under new bsd, so there is no license issue here. I plan to improve the current code to be more useful as well as adding perceptual diff. My initial idea was to use pdiff. It is under gpl but as it uses only for the tests suite it is ok. Sadly not for php. Alternatively the cmd pdiff can be used but it is then slower. In any case we can expose the image diff functions in ext/gd but it will need some work on the results to be useful in the wild. It should also be easy to write a script to port test from c to/from php to complete both side testing. Thanks for bringing that up :) Cheers Pierre