Zubrag.com
September 20, 2018, 10:24:12 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Watermark scripts  (Read 8835 times)
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« on: December 10, 2007, 05:50:19 AM »

Two scripts created:

- Watermark Image
This one will watermark one image using another image. It could be your company logo, etc.

- Watermark Image using text
This one will watermark image with your custom text, like your company name, site url, etc.

Both packages include example which would watermark all the jpg images in specified folder.

How to combine thumbnail generator and a one of these watermark scripts?

1) Combining with image watermarking

Open thumb.php for editing. Go to the end. There should be following code.

// generate thumbnail
$img->GenerateThumbFile($images_folder . $from_name, $thumbs_folder . $to_name);

After that code, we are adding code for watermarking:

// here put the path to the image which would be used as watermark
$watermark_path = 'watermark.png';

// END OF SETTINGS

// Load functions for image watermarking
include("watermark_image.class.php");

// Watermark image
$img = new Zubrag_watermark($thumbs_folder . $to_name);
$img->ApplyWatermark($watermark_path);
$img->SaveAsFile($thumbs_folder . $to_name);
$img->Free();

2) Combining with text watermarking

Open thumb.php for editing. Go to the end. There should be following code.

// generate thumbnail
$img->GenerateThumbFile($images_folder . $from_name, $thumbs_folder . $to_name);

After that code, we are adding code for watermarking (copying settings from  watermark_text_example.php):

// Watermark text
$text = 'zubrag.com';

// Watermark text color, Hex format. Must start from #
$color = '#000000';

// Font name. Case sensitive (i.e. Arial not equals arial)
$font = 'arial.ttf';

// Font size
$font_size = '8';

// Angle for text rotation. For example 0 - horizontal, 90 - vertical
$angle = 90;

// Horizontal offset in pixels, from the right
$offset_x = 0;

// Vertical offset in pixels, from the bottom
$offset_y = 0;

// Shadow? true or false
$drop_shadow = true;

// Shadow color, Hex format. Must start from #
// This may help to make watermark text more distinguishable from image background
$shadow_color = '#909009';

// END OF SETTINGS

// Load functions for image watermarking
include("watermark_text.class.php");

// create class instance
$img = new Zubrag_watermark($thumbs_folder . $to_name);

// shadow params
$img->setShadow($drop_shadow, $shadow_color);

// font params
$img->setFont($font, $font_size);

// Apply watermark
$img->ApplyWatermark($text, $color, $angle, $offset_x, $offset_y);

// Save on server
$img->SaveAsFile($thumbs_folder . $to_name);

// release resources
$img->Free();



Note: it will only work if you are saving thumbnail on the server.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC