D
D
Denis Ilinykh2011-04-15 11:49:52
Images
Denis Ilinykh, 2011-04-15 11:49:52

Insert watermarks in photos

Tell me how best to insert watermarks in the photo

  1. Generate all photos in advance with watermark overlay
  2. Generate photos on the fly using a script
  3. Write your own module for Nginx/Apache for photo processing


2.3 option naturally with caching from generated photos. to avoid re-processing.

The thing is that you need to store simultaneously a photo with a sign and without a sign.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
O
Ogra, 2011-04-15
@greyhard

If you are better with C/C++ than with PHP/Ruby/Python (or whatever you write the server side on), then point #3.
If your skill in the server language is higher or equal to C / C ++, then of course the second option.

M
Max Kuznetsov, 2011-04-15
@pluseg

Same for the second option. Here on Habré it was already considered how to make a watermark.

M
Masterkey, 2011-04-15
@Masterkey

you answered your own question: store two instances (the original outside the web directory), with a watermark in the target.
process photos in the process of adding: added a new product, saved the original image, applied a sign, saved.
in general KISS

T
the_ghost, 2011-04-15
@the_ghost

As I did.
1. I wrote a rewriterule in .htaccess so that all image accesses are transferred to a special php script.
2. The script checked if there is a picture with a watermark in the cache
2.1 If there is, then it gave this picture through readfile()
2.2 If not, then put a sign and save it to the cache. We output again, via readfile()
And here is the rule for .htaccess We check that it is a jpg or jpeg image ... ... so that this image is not requested from the admin panel and ... ... we send a request to the script In the script, the image is available in $ _SERVER ['REQUEST_URI']
RewriteCond %{REQUEST_URI} \.(jpeg|jpg)
RewriteCond %{HTTP_REFERER} !textpattern
RewriteRule \.(jpeg|jpg) /images/watermark/index.php [NC]

Y
yadeveloper, 2011-04-15
@yadeveloper

Of course, you need to generate images with watermark as they arrive (it can be delayed if there are a lot of images) - but not as requested. On the fly - you run the risk of getting "hurt".
I would write a cron script that fetches all files by find, with the last modification less than or equal to the call timeout of the cron-rule itself, and then use the console imagik. He copes with this task with a bang.
Total - the solution to your problem fits in one line

P
Puma Thailand, 2011-04-16
@opium

choose the first option and don't worry

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question