Not OpenGL; OpenGL isn't really suited for pixel-level operations which are what you're describing (it's more an object modelling library than one for image processing).
You might learn a bit from having a look at the Gimp's source code. You'd find that most such operations are really just a matter of having a big array of pixel structs and applying various mathematical operations to the data it contains. Lots of double-nested loops (for each row in the image, for each pixel in the row...).
Edit: I also just thought of PIL. It's written mainly in Python (porting it to PHP could be fun) with a bitmap-manipulation core written in C.
Edit 2