php - How would I programmatically crop an image to a non-rectangular shape? -


I want to crop a rectangular image into non-rectangular shapes. I know that if you really take it completely, then it is not possible. What do I want to do is that Image X stands for shaping Y on a transparent background.

For example, say I want to take a picture of the Idaho flag and shape it in shape, Idaho's condition I think I will do something like this:

  1. Create an image that has opaque pixels for the size of Idaho, transparent pixels everywhere
  2. for any type of bitmap Idaho state image
  3. Idaho State For each opaque pixel spot in the image A, copy the pixel related to the Idaho State flag image and place it on a blank, transparent canvas

Step 1 will be clearly done manually, but the rest will be programmatically done by me It seems that I have the right idea in general, but I do not know how I will approach the attributes, can someone tell me in the right direction?

As far as implementation technology goes, I'm a PHP guy, so using gdLibrary or something that works with PHP, maybe the best way for me will be

I think it would be easy to do just by adding a bitmask or alpha channel. In that case you will use a negative mask image of your size and then apply it on a regular image as a mask and then avoid in a transparent format. Ive never done this with GD or ImageMagick, but I think it's available as Jerry suggests

There is a similar blog post here that is a common SO question:


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -