tags:

views:

32

answers:

2

I am working on a script that creates a thumbnail and then will watermark the original image, but the script only creates the thumbnail and skips over the watermarking.

 $image = $data['json']->{'file_name'};
   $data['account'] = $account;

   $this->_insertintodb($account, $image);

   //Settings to create thumbnail
   $config['source_image'] = $data['json']->{'file_path'};
   $config['create_thumb'] = TRUE;
   $config['maintain_ratio'] = TRUE;
   $config['width'] = 125;
   $config['height'] = 125;
   $this->image_lib->initialize($config);

   if($this->image_lib->resize()) {
    $prep_thumb = explode('.', $image);
    $thumb = $prep_thumb[0] . '_thumb.' . $prep_thumb[1];
    $this->_moveimage($thumb, $account, TRUE);
   }

   $this->image_lib->clear();

   //Settings to create watermark overlay
   $config = array();
   $config['source_image'] = $data['json']->{'file_path'};
   $config['wm_type'] = 'overlay';
   $config['wm_overlay_path'] = getcwd() . '/design/overlay_watermark_transparent.png';
   $config['wm_vrt_alignment'] = 'middle';
   $config['wm_hor_alignment'] = 'center';

   $this->image_lib->initialize($config);

   if(!$this->image_lib->watermark()){
    echo $this->image_lib->display_errors();
   }

   $this->image_lib->clear();

Any ideas on why this is not working correctly?

A: 

Do you have the required dependencies? From http://www.codeignitor.com/user_guide/libraries/image_lib.html:

Note: Watermarking is only available using the GD/GD2 library. In addition, even though other libraries are supported, GD is required in order for the script to calculate the image properties. The image processing, however, will be performed with the library you specify.

Looks like you will need to install GD and then include it as your codeigniter image manipulation library.

hundredwatt
It works if you do either one separately, but when you try to do them together it does not
dennismonsewicz
I don't quite understand what your saying. Can you please clarify?
hundredwatt
If you run the functionality of watermarking by itself, it works. If you run the thumbnail functionality by itself, it works. But if you run them together, it doesn't.
dennismonsewicz
Try putting the code for the watermark before the thumbnail. If its a dependency issue, that might resolve it.
hundredwatt
A: 

If the watermarking isn't working, and you have the required dependencies, you should be getting error messages here:

if(!$this->image_lib->watermark()){
    echo $this->image_lib->display_errors();
}

Either those errors can help you more than we can, or we can help you more after you provide us those.

Dolph