Yes using the built in functions you can perform this easy
for image functions see GD
http://php.net/manual/en/book.image.php
for compression check zlib
http://php.net/manual/en/ref.zlib.php
heres an example of adding watermarks
http://www.sitepoint.com/watermark-images-php/
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