GD Library - Detecting colors and shapes, advice?
I have an image. Somewhere within this image is a rectangular box... Let's say it's 300px X 100px. It has a red border around it. I would like to be able to crop this image so that only the red box and the nearby area is left.
Is it possibly to do this programmaticall开发者_如何学JAVAy with PHP and GD? Can anyone provide me with some pointers on where to get started with this?
you can use http://www.php.net/manual/en/book.image.php to load an image and get a single pixels color.
count all the black pixels count all the black pixels from region 3 now you can calculate region 2 and also region 1
to count all the black pixels form region 3 just go trough each line. if everything is black, count everything. if not, count from left and from right all black pixels.
probably a better way todo it would be html5 canvas
精彩评论