Image Magick and watermarking

First of all, sorry if you find some mistakes in the text bellow :).

Just for helping those people who want to upload images with a watermark, I explain some changes I've made in the code.

I wanted to add a watermark only in the fullsize image, which is the size that I wanted to show in the public webpage (so, the original size image is hidden, because I don't want people download it; and the fullsize, which is resized to 800px, has the watermark).

Steps (omeka 2.0.3):
A) Do a backup!!

B) Show the fullsize (not original) in the public webpage:
(If Item File Gallery checked in theme configuration). Go to omeka/application/libraries/globals.php (line 2117).
Change this:
$linkAttrs = $attrs['link'] + array('href' => $file->getWebPath('original'));
For this:
$linkAttrs = $attrs['link'] + array('href' => $file->getWebPath('fullsize'));

C)Adding a watermark:

  • Move the image you want to use as a watermark to a folder (resize the image previously to, for example, 250 px). I have moved to C:\imagemagick\logo.png
  • Go to omeka/application/libraries/Omeka/File/Derivative/Image/Creator.php (go to the private function _createImage($origPath, $newPath, $convertArgs) and write at the bottom of the function:
/* New code */
if (strstr($newPath, 'fullsize') !== FALSE) {
   $cmd = join(' ', array(
      escapeshellcmd($this->_convertPath),
      escapeshellarg($newPath),
      'C:\imagemagick\logo.png ',
      '-alpha Set -compose dissolve -define compose:args=30 -gravity center -composite ',
      escapeshellarg($newPath)
   ));
   self::executeCommand($cmd, $status, $output, $errors);
   if ($status) {
      throw new Omeka_File_Derivative_Exception("ImageMagick failed with status code $status. Error output:\n$errors");
   }
   if (!empty($errors)) {
      _log("Error output from ImageMagick:\n$errors", Zend_Log::WARN);
   }
}

I have tried this tip.. but got no result...

--
Anas

It works now. My path was wrong. Sorry...

---
Anas