[Workaround] Bulk Watermarking


Joined: 2005-10-21
Posts: 6
Posted: Sun, 2005-11-20 22:21

Gallery2 provides a module called URL Rewrite. This module also allows watermarking images that are hotlinked (i.e. linked from another site).

By default, your own site domain is trusted. If you set it to not-trust your domain, all images are then shown with the watermark.


1. Go to Site Admin
2. Click on Watermarks under Display
3. Select "Hotlink" radio button for the watermark you want to use

4. Install URL Rewrite module
4.a. Click on modules
4.b. Install URL Rewrite
4.c. Activate it

5. Go to URL Rewrite Administration
6. Activate Watermark hotlinked images
7. Save

8. Click on the Setup tab
9. The approved referers already lists your own domain. The code prevents you (or atleast me) from removing it.
10. So there's nothing to do here. (unless you want images to not be watermarked from some domain)

This will add the watermark to your images if some other site displays those images.

To make G2 show the watermark on your site as well,
Open .htaccess file in your G2 directory on your web server.

Look for these lines:

RewriteCond %{QUERY_STRING} view=core.DownloadItem
RewriteCond %{QUERY_STRING} itemId=([0-9]+)
RewriteCond %{HTTP_REFERER} !://www\.YOUR-SITE\.com/ [NC]
RewriteRule . /gallery/main.php?g2_view=watermark.DownloadItem&g2_itemId=%1 [L]

And remove, or comment (add a #) the third line to make it:

RewriteCond %{QUERY_STRING} view=core.DownloadItem
RewriteCond %{QUERY_STRING} itemId=([0-9]+)
#RewriteCond %{HTTP_REFERER} !://www\.YOUR-SITE\.com/ [NC]
RewriteRule . /gallery/main.php?g2_view=watermark.DownloadItem&g2_itemId=%1 [L]

That should do it. :)

Note: The .htaccess file will be modified the next time you change some G2 settings. So you'll have to manually do this again.


Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-11-20 22:27

heh, you might want to add this workaround as a howto to codex.gallery2.org .

note; as far as i understand the hotlink watermark feature, it doesn't cache the watermarked image, so they get generated on each request for each image / thumbnail shown. this will drive the server load up and most servers will get extremely slow / unresponsive as soon as there are more than 2, 3 concurrent users.


Joined: 2003-05-01
Posts: 219
Posted: Mon, 2005-11-21 00:12
navadasha wrote:
That should do it. :)

Thanks very much for this - I'm sure I'm not the only one who appreciated this. Whether my web-host likes it or not remains to be seen ;)


Joined: 2005-11-21
Posts: 2
Posted: Mon, 2005-11-21 22:00

Nice post. You've just saved me LOTS of time. THANK YOU VERY MUCH

Given the performance issues associated with this tweak, any idea which would be more efficient: netpbm or ImageMagick? (given that one of them is gonna run every time someone views a pic)

Also, any idea what the ETA on a real bulk watermarking feature is? I see it's been the top rated feature request at sourceforge for some time now.

Thanks again.

nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-11-22 07:18

Probably won't see any new features until at least 2.1 is released. I don't know if the devs are currently working on bulk watermarking or if they are concentrating their efforts on other tasks at this time. Sometime in Jan/2006 or early 2006 we should see G2 2.1
Like Gallery? Like the support? Donate now!!! See G2 live here

eppcommk's picture

Joined: 2005-12-15
Posts: 22
Posted: Sat, 2005-12-17 12:14

Thank You. That has been very helpful.
See the fun in Macedonia www.epp.com.mk/gallery2

eppcommk's picture

Joined: 2005-12-15
Posts: 22
Posted: Thu, 2005-12-29 08:50

Yes it was helpfull.it worked for some time.now my account is suspended:(

eppcommk's picture

Joined: 2005-12-15
Posts: 22
Posted: Thu, 2005-12-29 08:55

sorry.please delete extra post.

claire_v's picture

Joined: 2006-03-31
Posts: 31
Posted: Fri, 2006-03-31 22:29

This is a great post for bulk watermarking. I am 99% there, but can't find the .htaccess file on my web server? Can anyone help?


Joined: 2006-03-26
Posts: 4
Posted: Sat, 2006-04-01 01:40

My own personal work-around is to simply bulk watermark my web images in Adobe Photoshop CS2 before I even upload them to the gallery. I just created an action for my copyright and then add it to the photos. That way I know that even if people try to save any of my photos directly from my site, they will have a big fat watermark on them. It makes things a whole lot easier. :)

eppcommk's picture

Joined: 2005-12-15
Posts: 22
Posted: Thu, 2006-04-20 18:52

Well, I figured out even a better way. If it helps to anyone. I found a program that does bulk watermarking. So now, I don't have to work on all the photos one by one (in photoshop), but instead all I have to do is click a button and all the photos in a folder get a watermark and reduced quality (less kb).
It works fine. I don't have to worry anymore.