Comments for "Image_Diff"

» Submit Your Comment
Please log in to enter your comment. If you are not a registered PEAR developer, you can comment by sending an email to pear-dev@lists.php.net.
» Comments
  • Matthew Fonda  [2009-09-03 19:44 UTC]

    Looks great so far! A few minor comments:
    - Image_Diff::handleFileErrors() could probably be protected instead of private
    - In Image_Diff::nearlySame(), it may be better to check if the parameters are gd resources instead of checking if they are string, that way at the point where you first call gd functions you are 100% sure you are passing them a valid image resource.
    - It might be nice to return the measure of difference instead of just true/false

    On a side note, the ImageMagick 'compare' utility has some cool features such as outputting an image highlighting the differences between the two images being compared. I'm not sure how difficult that would be to implement, but it could be a cool feature to have!
  • Daniel O'Connor  [2009-09-04 05:57 UTC]

    Is there any compelling reason to make these static methods?

    Being static means I can't mock them out, and makes them more like namespaced functions than an Image_Diffing object.

    Ie:
    Image_Diff::nearlySame()

    could easily be

    $diff = new Image_Diff();
    $diff->nearlySame();

    while having none of the drawbacks of statics (http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/)