News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

watermark on product image

Started by sahar-onyx, October 25, 2014, 12:36:31 PM

Previous topic - Next topic

sahar-onyx

hi
how can I use watermark on product image?

I have   VirtueMart 2.6.0 -- joomla 2.5.20

I applying under document but not working

-------------------------
Apply Watermark image into Product Image of Virtuemart



Problem: When Creating an shopping website, we would like to apply a watermark image - logo and website name - on every picture of products. It is seem easy by this way: use an watermark program to apply icon on product picture, then upload that picture on hosting. Take a long time if you have over 50 products.
I want to do this work automatically, It means watermark picture will be applied in to all picture (old and new) of website

Solve: I do this work on Joomla 2.5 and Virtuemart 2.0. But I think it is comfortable for every happen load and show Image.
•Step 1: Create file .htaccess on folder contain image, with Virtuemart 2.0, this folder is <your_domain>/images/stories/virtuemart/product.



RewriteRule ^(resized)($|/) - [L]

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f

RewriteRule \.(gif|jpeg|jpg|png)$ watermark.php [QSA,NC]



•Step 2: Create file watermark.php at same folder of .htaccess with content:


<?php

// watermark.php
// Path the the requested file

$path = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
// Load the requested image

$image = imagecreatefromstring(file_get_contents($path));$w = imagesx($image);$h = imagesy($image);
// Load the watermark image

$watermark = imagecreatefrompng('watermark.png');$ww = imagesx($watermark);$wh = imagesy($watermark);
// Merge watermark upon the original image (centred)

imagecopy($image, $watermark, (($w/2)-($ww/2)), (($h/2)-($wh/2)), 0, 0, $ww, $wh);

// Send the image

header('Content-type: image/jpeg');imagejpeg($image,null,95);
exit();?>

•Step 3: Create an watermark.png with transparent background and upload to that folder.
Done.

Now you can test all image file in folder <your_domain>/images/stories/virtuemart/product have watermark if you call them on your website

Note: the code line RewriteRule ^(resized)($|/) - [L] in .htaccess file ensure that all thumbnail file in resized folder will be not watermarked. If you want to watermark on both thumbnail and large picture, you can remove that line
-------------------

please help me
is very important for me
thanks