Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorddejong
    • CommentTimeNov 8th 2005 edited
     
    So, I have a 200x100 watermark I want to apply to my images, and have done so successfully with this code:

    plog-functions.php, line 79:
    if ($type != 'small') {
    $phpThumb->fltr = array("wmi|images\watermark.png|BR|20|5"); }

    However, it doesn't fit on my 100x100 album thumbnails (obviously). Hence the if-condition, "if making small thumbnails, don't stick the watermark on". But, it's failing the if-condition and putting the watermark on all of the images. I'm stumped as to why, and hoped Mike or someone else might be able to help.

    Also, if anyone wants help using the other features of phpThumb, I played with it rather extensively this evening and will gladly help them out.

    Regards,
    Derek
    • CommentAuthorjack
    • CommentTimeNov 8th 2005
     
    I'm not really into PHP, but doesn't the if-statement say "if type is NOT small"? Then the filter would only be applied when the picture is not small. Would make sense. Who wants a watermark on a small thumb?

    But this is probably a stupid answer... :)
    •  
      CommentAuthormike
    • CommentTimeNov 8th 2005 edited
     
    I think that's what he is saying, he DOESN'T want to watermark small thumbnails, hence the logic.

    I had similiar problems with that $type variable, even when it is set to 'small' that logic won't return the proper value using the != or == operators. You may need to use the PHP function strcmp, which compares two strings.

    if (strcmp('small', $type) == 0)

    If this doesn't work, you can use my really crappy work-around (which I used liberally in the generate_thumb function :P)
    if ($thumb_config['filename_prefix'] != '')
    • CommentAuthorddejong
    • CommentTimeNov 9th 2005
     
    On line 18, generate_thumb() has this signature:
    function generate_thumb($path, $prefix, $type = 'small')

    Is that assignment doing something bizarre? I've never seen that syntax, but until I wondered if it was causing problems. You're clearly a much better php programmer than I, but wondered if that wasn't the cause of the problem.

    Thanks for the fixes, I will try to implement them shortly.

    Regards,
    Derek
    • CommentAuthorjack
    • CommentTimeNov 9th 2005
     
    Can you show us the result Derek? I would like to see how it looks and works.
    • CommentAuthorddejong
    • CommentTimeNov 9th 2005 edited
     
    Sure, Jack. It's hosted temporarily on my own server, but it's a project done for a photographer friend of mine, and my first experience with Plogger. I won't post it into the examples thread yet, until it's finished, but here is a temporary URL in the interim. You'll notice the links to information I don't have (like his Bio and such) don't work, because I need to get them from him, but the galleries et al should work fine. Also keep in mind many of the photos will not make the actual website, but were needed for testing, etc.

    He's admittedly computer-unfriendly, so he didn't want a CMS or blogging platform; he wanted something he could upload pictures to, organize them, and be done with it. I wanted a gallery that was easily-customizable, powerful, XHTML & CSS friendly, but still offered him that simplicity. It's a tall order.

    I can't decide how big to make the large thumbs, because he wants good images but doesn't want them breaking the viewport, which is understandable.

    Notice the CSS isn't quite finished, so there are some cramped spaces which need fixing, and I'm not sure where the thumbnail navigation (via Plugger) will end up. Looks better in Firefox than anything else, but the CSS should be almost spot-on with any CSS1 compatible browser. Still have to get it sitechecked (eventually) in CSS-Discuss.

    http://www.automatamedia.com/royer

    The watermark is a PNG-24 Alpha transparent image, saved to /images/watermark.png. Then, on line 85 of plog-functions.php, I inserted (thanks to Mike for the workaround):

    if ($thumb_config['filename_prefix'] != '') { // add only for large thumbs
    $phpThumb->fltr = array("wmi|images/watermark.png|BR|50|5";); }
    // watermark-image, filename, corner (bottom-right), 50% opacity, 5% edge margin

    phpThumb then parses the string with the pipes ("|") to get the filter settings. For info about that, check out your Plogger install in /lib/phpthumb/docs, or check out phpthumb.sourceforge.net.

    Regards,
    Derek
    • CommentAuthorjack
    • CommentTimeNov 9th 2005
     
    Derek, I think that site already looks very good. I will show my gallery soon, it's completely intergrated into wordpress, so only three columns wide. But when I see your example I'm wondering again if a stretched full page gallery wouldn't be nicer. :(
    My photography is also serious, although also a lot of room for other stuff.

    I would make the thumbs a bit larger. I noticed that when making them about 90 or 100 px wide they look like little stamps and my eye catches only color, but when I make them about 120 px they somehow look better, more like an image on itself instead of a teaser.

    I notice the large images take a long time to load.
    • CommentAuthorddejong
    • CommentTimeNov 9th 2005
     
    That will be because I wiped all of the thumb cache for watermark testing, so right now it has to generate each one fresh. As people make it through all of the galleries (I would make an initial run on the live site), the thumbs will be generated and cached and make load times a lot better.

    Thanks for the comments,
    Derek
    • CommentAuthorjack
    • CommentTimeNov 9th 2005
     
    One more: Why does he want a watermark in the first place? For some kind of simple protection or for publicity?
    • CommentAuthorfloo
    • CommentTimeNov 9th 2005
     
    I was just looking how to add a similar system.

    I used the derek's script, wich works fine in local. But it seems to have some problems on my server. I empty the thumbs cache directory, but all thumbs are re-created without the watermark :/

    I'll try to sort it out now
    • CommentAuthorjack
    • CommentTimeNov 9th 2005
     
    And yet another question for Derek: Did you fill the css dropdown with a (new?) plogger function or did you manually add the categories?
    • CommentAuthorddejong
    • CommentTimeNov 9th 2005
     
    The watermarking is for both branding and protection, though I agree it won't work in all circumstances, it's harder for somebody to remove then take credit for it. The images aren't small enough they can be used in print, etc, so I'm not too worried about it. Secondly, if the images do make their way around, one should be able to find the website by googling his name (yes I considered adding the URL, but it makes the watermark look sloppy and way too long).

    And yes, I made a new function generate_album_menu that returns an unordered list of all galleries and are linked to the menu (much like the Jump Menu). That way, when he adds albums (with pictures), they will appear in the menu.

    Derek

    Floo: Make sure you upload the watermark to the server, too.
    • CommentAuthorjack
    • CommentTimeNov 9th 2005
     
    Did you create a total new template for that site? I mean, this function (dropdown or not) would be great for an automatic list of collections in the sidebar of a site (my site ... :) ). I know Mike is working on/or has completed a similar function. I'm just not sure how this will be used in the future. There is this template system coming up, I know that, but perhaps Mike could tell us a little bit of how this will work? Like now I creatend this index page for plogger which resembles my wordpress site. No problems here, but instead of the wordpress categories on the left it would be great to have a list of plogger collections instead when the visitor switches from weblog to gallery. Then by clicking a collection the albums can be shown just like now, with thumbs. It would be easiest if some kind of function could be placed anywhere in the page, NEXT tot the three php includes required at this moment.

    ... just thinking aloud here. :)

    As to the watermakering: protection would be better when the watermark would be much larger, covering the entire image, but that's ugly. I'm very skilled in using the photoshop stamp ;), so 'stealing' an image would be easy with the current stamp. Not that I'm thinking about that! But as a brand... nice. I think that when this is working ok/faster loading it would be a great standard feature in plogger.
    • CommentAuthorddejong
    • CommentTimeNov 9th 2005
     
    Well, there is an option in phpThumb to tile the watermark. I might do that instead, but very lightly. Then again, it's hard to do without ruining the image; if people are really intent on taking the image, there isn't a whole lot you can do. Even digital watermarking isn't sufficient.

    Btw, once you include gallery.php, you can call any function anywhere on the page.

    And sure, I will post the function shortly.

    Regards,
    Derek
    • CommentAuthorjack
    • CommentTimeNov 10th 2005
     
    If I'm correct, the above scripting will not work if intermediate pictures are deactivated. I only have the thumbs + the original images. I think it is easy to get the watermarking in the original sized/large images, but where?
    • CommentAuthorddejong
    • CommentTimeNov 10th 2005
     
    Check out the phpThumb page, should give you a good start. Just call the images through phpThumb and force the watermark.
    http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php
    • CommentAuthorpuk
    • CommentTimeNov 14th 2005 edited
     
    Hey guys, this really interests me, as i also am writing sites for local artists/photographers etc and the added piece of security, and the lack of bother having to watermark with photoshop make this really good for me!

    Could anyone point out what i'd have to include to get this going on my script, my gallery.php is hardly modified, so what code would have to be placed where? I know nick-c is making a plugin for this reason, but a quick fix would be wonderful!

    I too would also like to watermark the smaller thumbs, and probably tiled would be better, i've looked into this before and the php is still a bit ahead of me, if anyone could give me a few points in the right direction i would be very grateful!

    cheers
    •  
      CommentAuthormike
    • CommentTimeNov 14th 2005
     
    puk, you can use Derek's code above. Just add,

    if ($thumb_config['filename_prefix'] != '') { // add only for large thumbs
    $phpThumb->fltr = array("wmi|images/watermark.png|BR|50|5";); }

    to plog-functions: generate_thumbnail()

    Change that string "wmi|images/watermark.png|BR|50|5" to suit your needs. The format of the string is based on these rules:

    "wmi" (WaterMarkImage)
    [ex: &fltr[]=wmi|<f>|<a>|<o>|<m>] where
    <f> is the filename of the image to overlay;
    <a> is the alignment (one of BR, BL, TR, TL, C,
    R, L, T, B, *) where B=bottom, T=top, L=left,
    R=right, C=centre, *=tile);
    <o> is opacity from 0 (transparent) to 100 (opaque)
    (requires PHP v4.3.2, otherwise 100% opaque);
    <m> is the edge (and inter-tile) margin in percent
    - "wmt" (WaterMarkText)
    [ex: &fltr[]=wmt|<t>|<s>|<a>|<c>|<f>|<o>|<m>|<n>]
    where:
    <t> is the text to use as a watermark;
    <s> is the font size (1-5 for built-in font, or point
    size for TrueType fonts);
    <a> is the alignment (one of BR, BL, TR, TL, C, R, L,
    T, B, * where B=bottom, T=top, L=left, R=right,
    C=centre, *=tile);
    <c> is the hex color of the text;
    <f> is the filename of the TTF file (optional, if
    omitted a built-in font will be used);
    <o> is opacity from 0 (transparent) to 100 (opaque)
    (requires PHP v4.3.2, otherwise 100% opaque);
    <m> is the edge (and inter-tile) margin in percent;
    <n> is the angle
    • CommentAuthorddejong
    • CommentTimeNov 15th 2005
     
    Mike, did I ever get a response about this assignment:
    On line 18, generate_thumb() has this signature:
    function generate_thumb($path, $prefix, $type = 'small')

    Now, coming from a Java background, that makes no sense at all. But, I thought it might mean that if there were no third parameter, that it would assign "small" to type. But, is it possible that this is what was causing $type to evaluate incorrectly? Just a thought.

    Regards,
    Derek
    •  
      CommentAuthormike
    • CommentTimeNov 15th 2005
     
    Your exactly right, that is what it is supposed to do.

    Now that you mention it, maybe it isn't working at all. I will have to look into it.
    • CommentAuthorddejong
    • CommentTimeNov 15th 2005 edited
     
    What about instead using two functions with different signatures?

    function generate_thumb($path, $prefix) { // the 2-parameter version
    generate_thumb($path, $prefix, "small"); // calls the 3-parameter function
    }
    function generate_thumb($path, $prefix, $type) { // the 3-parameter signature
    ...
    }
    •  
      CommentAuthormike
    • CommentTimeNov 15th 2005
     
    I think this is unnecessary, there is no reason why the code we have shouldn't work. You can see here, PHP is designed to use default parameters (as seen above) to avoid declaring multiple function prototypes (as seen in your example), there must be something else going on.

    Example: http://www.hudzilla.org/phpbook/read.php/4_15_5