Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Return RGB from Selected Area

    Hi! Using PHP 5, can an a section of an image be selected, and return the RGB values of 3 of most most average colours, contained in the selected area of the image?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    It's possible, but it won't be very easy. This would be the general idea:
    Load the image into an image pointer,
    Copy the section you want to another pointer,
    Loop through the pixels using imagecolorat() to read each pixel and add it to an array of counters,
    Sort the array, etc.

    There's a code snippet that might be helpful here.

  • #3
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah ha Cheers!


  •  

    Posting Permissions

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