Jump to content

Downloadable Product - Watermark Image


Recommended Posts

Hi Everyone.

This is my first post - I love prestashop and I want to know for a charity event i am helping organise whether I could set up a product whereby the customer gets a downloadable image / ticket and when the get-file.php or whatever goes to grab the image can it Watermark it with a unique code or customer name or something so that image / ticket cannot be copied?

Would really appreciate your expertise.

Thank you.

Link to comment
Share on other sites

Please follow below instructions

install watermark module (back office - modules - search for watermark and click install)
after install the watermark module, click configure link and go to the configure screen,
upload your watermark (must be gif format)
then go to back office - preference - images - regenerate product images

hope this works for you.

Link to comment
Share on other sites

Hi,

I dont think you understand what I mean, upon checkout I want the customer to receive their downloadable product which will be in the form of an image (ticket) but I want their name and order number automatically watermarked across this image.

Can this be done?

Thank you

Link to comment
Share on other sites

Sorry for my misunderstanding.
I think it is also possible, but it will require some coding. The basic idea is that
1. generated a watermark GIF image dynamically by using the name or order number
2. apply the generated GIF watermark to product image to generate new image, you create the new image on fly and send this image to users browser when user click download.

for 1. you can search internet, there should be some free image generator to do that.
for 2. you check the code which implement Back office - Preference - Images - regenerate image

Link to comment
Share on other sites

We had to do something similar. We create reports dynamically based on the product after the purchase is complete. Since we only use PayPal, it really wasn't as difficult as I expected.

What we did was create a new class that generates our reports and call it in PaymentModule->validateOrder(); We did this right after the new order hook around line 274 in 1.3.1.

For each product in the cart, we check to see if(intval($id_order_state) == _PS_OS_PAYMENT_) and then called our ReportGenerator class to build the report if it was > 14 days old or didn't exist. The ReportGenerator class stores the report using the same "physically_filename" as in the database and when the email is sent with the link, it works.

You could do the same thing but write a class to generate a watermark on your image and store it with the "physically_filename" that is stored in the database.

Link to comment
Share on other sites

Or even simpler would be to do it in get-file.php.

Do this before the first header is set.
You would take the filename, which is in the variable $filename. Use the code in this script
to watermark it.
http://911-need-code-help.blogspot.com/2008/11/watermark-your-images-with-text-using.html

You may need to modify that code to get the desired results but it should be fun testing!

Link to comment
Share on other sites

Thank you MrBaseball34 - I thought it would be the get-file.php but as I said I am not a coder and so am stuck by this.

I found a similar script at http://www.phpjabbers.com/put-watermark-on-images-using-php-php20.html

but is there anyone who wouldnt mind spending 5 mins in creating a new get-file.php page that incorporates this code to create text of the order number or customer name over the downloadable product JPG image called ticket.jpg

??
Thank you again.

Link to comment
Share on other sites



If the downloaded "ticket" is intended to be printed & presented in-person for an event... we're not really doing much to prevent duplication / counterfeiting. Shrug, better than nothing, I guess.

Now would that not be the purpose of the unique ID#? The presented tickets would be verified against a list of ID#s that had been sold, I presume to prevent it.
Link to comment
Share on other sites

  • 3 months later...
owtechnologies, I have attached to this post a modified version of get-file.php
(modified from the file in today's distro of Prestashop v1.4Final)

How to use:
rename your existing get-file.php and substitute the copy from the zipfile in its place.

How to test:
Posing as a customer, download a purchased virtual product.
If the file is NOT a jpg, it will not be disturbed.
If the file IS a jpg, it will be watermarked -- center overlaid with uniqueID text, plus the URL of your shop

Prerequisites for use:
You must have the files for the "artichow" module present (these are native to the PS distro).
The Artichow module does not need to be installed or enabled.
Just bear in mind that the modified get-file code expects to find the font file
modules/graphartichow/artichow/font/TuffyBold.ttf
(To change the font, edit get-file to reflect the path to whatever ttf file you wish to use.)
-=-
Also, all of your virtual product JPGs should be at least 715px wide.
If they are not, the uniqueID text string will overflow past the edge.
(To accomodate smaller images, you would need to edit the get-file code and specify a smaller font size.)

AM CURIOUS TO HEAR YOUR "USE CASE" FOR SUCH WATERMARKED "PAID DOWNLOADS".
I SURE WOULDN'T EXPECT CUSTOMERS TO GRACIOUSLY ACCEPT SUCH A THING.

How to customize (font size, color, location, etc)
refer to:
imagettftext()
http://us.php.net/manual/en/function.imagettftext.php
imagecolorallocatealpha()
http://us.php.net/manual/en/function.imagecolorallocatealpha.php
imagejpeg()
http://us.php.net/manual/en/function.imagejpeg.php


Hey,

I tried your get-file.php with a 800x600 jpg downloadable product and it didnt watermark it.
Checked all your pre-reqs.. same version etc

This would be very handy for my shop right now

Thanks heaps for sharing too
Link to comment
Share on other sites

Personally, I wouldn't do it in get-file.php. I wrote a new class to build dynamically generated reports that we sold and called it from the Payment module after payment was made. This would be the place where I would create the watermark image and set the downloadable link.

Let me see if I can find that code. It was for PS v1.3.1.

Link to comment
Share on other sites

×
×
  • Create New...