Results 1 to 2 of 2

Thread: How do you convert an image to black and white in PHP

  1. #1
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default How do you convert an image to black and white in PHP

    Hi,

    How do you convert an image to black and white in PHP.I see this in one site and is a great future to any site.

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can use the GD library.
    http://www.php.net/manual/en/function.imagefilter.php
    See "IMG_FILTER_GRAYSCALE"

    Be warned, though, that it may be slow especially on larger pictures. If there is a way you can batch pre-process your images first that will save you server difficulties (slow images, stressed processor), or you could save them when they are converted the first time (check if it's saved, if not, convert and store, but then only do it once).

    There's also the option of image magick, though I'm not sure how you'd do it with that. (It's basically an alternative to GD, though it has its own problems, and isn't bundled by default.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •