views:

1312

answers:

2

Is there a reasonably straightforward way to copy a circular area from one image resource to another? Something like imagecopymerge except with circles or ovals etc?
If possible, I want to avoid having to use pre-created image files (any oval shape should be possible), and if there's transparency colours involved they should naturally leave the rest of the image alone.

Reason I'm asking, I have a few classes that allow to apply image operations inside a "selected area" of an image, which works by first deleting that area from a copy of the image, then overlaying the copy back on the original. But what if you want to select a rectangle, and then inside that deselect a circle, and have the operations only affect the area that's left?

+1  A: 
phalacee
"3. Create a mask png image of the area you want in the circle/ellipse (a black image with a white shape on it, with black set to the colour of alpha transparency) - $mask. 4. Copy $mask over the top of $firstcopy maintaining the Alpha transparency." Don't I now have the original image with either a black or white circle on it? Or a transparant image with a black or white circle? Also, if there's black or white in the selection itself, won't that go wrong in the final stage when merging everything again?
MSpreij
@MSpreij I've added a code sample with details on what you need to do ... I've tested it and know it works too
phalacee
Thanks! I'll try it later this evening.
MSpreij
@MSpreij: Did that solve the problem you were having?
phalacee
A: 

What if "Magic Pink" is in the image... Then it will not work

If you run one of these colour replacing scripts first it will stop any chance of that happening.

Mark