Jump to content

php image manipulation: masking


HaLo2FrEeEk

Recommended Posts

Does anyone know of the top of their head if there is a function built in to php that will allow me to apply image masks to an image?  If you don't know what a mask is, it is a black or whitelayer on an image that is interpretted into either opaque or transparent.  I need to take a base image and cut it out on the fly (the image will be different every time in style, and color) leaving just a certain part of the image, the rest will be transparent.  If there is no built in function, then can anyone refer me to a class created for this purpose?  Thank you.

Link to comment
Share on other sites

Well, if you have, say, an image and your mask image is same size but with white background with a blue circle in the middle (the mask)

 

pseudocode

for x = 0 to imagewidth
   for y = 0 to imageheight

         if pixel at xy in mask is white then
             output white pixel in output image (or other transparent color)
         else
             copy pixel color from image at xy to output image
         end if
   end for
end for

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.