how to crop a "Arbitrary" shape from an image
Posted: Fri Jul 07, 2006 10:02 pm
If GD2 library provides functions to be able to do that?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
I have checked the functions, but could not find a way to clip an arbitrary shape(e.g. triangle) out of a photo. It seems that it can only clip rectangle shapes.
That's the problem with Java in my opinion .. practically everything has been provided so people forget how to write their own code. PHP is pretty bad for it too.wasedaxiao wrote:I have checked the functions, but could not find a way to clip an arbitrary shape(e.g. triangle) out of a photo. It seems that it can only clip rectangle shapes.
In Java, it provides such APIs to do that. So i have to implement this functions by myself?
Any idea, please.
Yes, I agree with you. As students, it's better not to use exist APIs for learning.onion2k wrote:That's the problem with Java in my opinion .. practically everything has been provided so people forget how to write their own code. PHP is pretty bad for it too.wasedaxiao wrote:I have checked the functions, but could not find a way to clip an arbitrary shape(e.g. triangle) out of a photo. It seems that it can only clip rectangle shapes.
In Java, it provides such APIs to do that. So i have to implement this functions by myself?
Any idea, please.
Anyway .. to crop an arbitrary shape you'll need to work out the rectangular bounds of the area you want, copy that rectangle to a temporary canvas, then work out which bits of that rectangle are outside the area you want to keep, and you'll need to set those pixels to transparent. That'll give you a temporary image you can then copy to another image.