Member
Member
timo   2007-11-12, 17:48
#1

I love the new zenphoto 1.1(.2) and am very excited about having all of the features I've gone though on my own and hacked together work out of the box. However, one thing I had going before I upgraded was image watermarking. This is a feature now officially supported, but it falls short at a critical spot. When you click to download the full size image, that has no watermark.

I solved this before by changing getFullImageURL() to getWateredFullImageURL() on the image page, this new function I wrote into template-functions.php. This takes you to a new page I made, a simple php script to on the fly return the image with a watermark.

This is a good way to consistently watermark your images, although it has it's downsides (broken after every upgrade). I think something to achieve the same means should to be included in the standard release.

This is full.php and it is put in my theme folder:




`

This part goes after the function ```getFullImageURL()`

function getWateredFullImageURL() {

global $_zp_current_image;

$hi = "/gallery/page/full/?a=" . $_zp_current_image->getAlbumName() . "&i=" . $_zp_current_image->getFileName();

return $hi;

}

`

Junior Member
Junior Member
marrs   2007-11-12, 18:33
#2

Thanks timo
I will try this ASAP and get back with the results..

Member
Member
aitf311   2007-11-12, 19:18
#3

Awesome work timo!

Member
Member
timo   2007-11-12, 19:32
#4

A couple things need to be done for it to be viable:
-add a mod_rewrite rule to .htaccess so it looks like it's a regular image. When you try to save a watermarked image from this it's filename is index.html?a=Album not IMG_2314.jpg.
-relocate this script to zp-core or incorporate it into i.php so it's not dependent on the theme.

I would love to spend a couple of days working the kinks out of it and learning mod_rewrite but I'm an overbooked high school senior.

Member
Member
sbillard   2007-11-12, 19:48
#5

timo:

I thought seniors just had to ditch classes to get more time . Anyway, if you do get some time to work this out, we'd be glad to add it to ZP!

Member
Member
aitf311   2007-11-20, 00:26
#6

timo: would you mind adding this to the zenphoto hacks page? http://www.zenphoto.org/trac/wiki/ZenphotoHacks

We are getting ready to have a much better addons section and it would be great if it could be featured.

Also, to use this in your theme and not have to modify template-functions you could put the function at the top of your themes page or make a customfunctions.php page and include it in your theme page

Member
Member
timo   2007-12-13, 01:44
#7

Someone emailed me asking for some further clarification of this hack. For this script to work one needs to fix the hard links to fit your setup. When the php code says /var/www/gallery/albums/ or just /gallery/ you need to change it to how it's set up on your computer. It may be "/var/www/t413.com/zenphoto/albums/" for example. There are three other instances of this hard linking you need to change, just look for /gallery/ and change that to how you named your zenphoto install folder.

I forgot to update my improved script I made a few weeks ago, all you have to do is add header('Content-Disposition: attachment; filename="' . $_GET[i] . '"'); after the first header line, and this way the full image will have the correct filename when downloaded. If you don't want the image to download but show in the browser change attachment to inline.

Member
Member
sbillard   2007-12-13, 02:35
#8

timo:

Some suggestions.

if you change the url to something like index.php?p=full.php&album=&image= then you will travers through the normal zenphoto load to get to your full image page. This means that things like $_zp_current_gallery->getAlbumFolder() are available for your script. Also, you won't have to hard code in the URL information to get to the page in the getWateredFullImageURL function.

These things would go miles to making your functions more easily used by zp theme makers.

Member
Member
sbillard   2007-12-15, 03:00
#9

This feature will be available in the 1.1.3 release due out soon. Themes will have to use the new function getProtectedImageURL() in place of getFullImageURL(). All the distributed themes have had this change made.

BTW, this change also supports password protected albums. If you haven't logged into the album, you won't be able to view the image.

Member
Member
timo   2007-12-15, 18:56
#10

Sbillard: That's awesome, I'm glad it's being worked into the standard release. I'm sorry I couldn't help with it, perhaps after all my college apps are done in February I'll have time to help develop.

Also, I was looking through google but never found a good answer: is there a way to preserve the exif data from the original photo when the watermark is added? That may be something to look into, although it's not too important..

Member
Member
sbillard   2007-12-16, 01:17
#11

timo:

You were a great help. It was your idea and basic design that was incorporated.

As for the EXIF data, I don't know. Maybe if we move to a different graphics library. You could put a new feature ticket into trac so we will remember if we do make the move.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.