Yes using the built in functions you can perform this easy

for image functions see GD

for compression check zlib

heres an example of adding watermarks

then once its been watermarked just compress it and move it to another directory or store it in the database(not recommended).

hope this helps