Author Topic: Product Images Watermark in Virtuemart 3  (Read 3616 times)

framos41

  • Beginner
  • *
  • Posts: 21
Product Images Watermark in Virtuemart 3
« on: July 14, 2015, 18:45:40 pm »
Hello is there a way to watermark product images in virtuemart 3?

Thank you!

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27637
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.11 10252 on Joomla 3.9.14 PHP 7.0.33

framos41

  • Beginner
  • *
  • Posts: 21
Re: Product Images Watermark in Virtuemart 3
« Reply #2 on: July 14, 2015, 23:50:31 pm »
Thank you!

But does that code work for Virtuemart 3 and joomla 3.4?

Quote
This is a prefectly easy and free solution for watermaking images :::

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

CREDITS: mtkcode.blogspot.hu/2013/07/apply-watermark-image-into-product.html


Regards!

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27637
  • Always on vacation
    • Jenkin Hill Internet
Re: Product Images Watermark in Virtuemart 3
« Reply #3 on: July 15, 2015, 10:44:55 am »
It is .htaccess, not Joomla or VM code so should be version independent.

I use Photoshop to embed watermarks in images before uploading where it is necessary so never tried anything else.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.11 10252 on Joomla 3.9.14 PHP 7.0.33

jarlu

  • Beginner
  • *
  • Posts: 29
  • A beginner
Re: Product Images Watermark in Virtuemart 3
« Reply #4 on: December 17, 2019, 22:37:46 pm »
Hello, I use your script, but in my eshop I have in some images spaces in file name and for this images cannot create watermark. When I click on image it is shown me notice "The requested content cannot be loaded." Do you have for me some advice (off course without change images names)?  Thank you

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27637
  • Always on vacation
    • Jenkin Hill Internet
Re: Product Images Watermark in Virtuemart 3
« Reply #5 on: December 18, 2019, 10:40:29 am »
I always use an underscore if a space is required in a filename. I'd guess that the .htaccess code could be modified, but this is something I have never done.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.11 10252 on Joomla 3.9.14 PHP 7.0.33

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2530
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Product Images Watermark in Virtuemart 3
« Reply #6 on: December 18, 2019, 13:43:25 pm »
Spaces in filenames used for webapplications is always something to avoid. Use Jenkins advice and replace with '_'.

Jörgen @ Kreativ Fotografi
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)