forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: alexandre596 on April 13, 2012, 04:36:33 am

Title: watermark old pictures?
Post by: alexandre596 on April 13, 2012, 04:36:33 am
well, at first, I didn't want to watermark my pictures at my coppermine gallery
but now I do, and I want to watermark all the old pictures, is that a way of doing it?

thanks
Title: Re: watermark old pictures?
Post by: nickelas on April 13, 2012, 07:10:36 am
I belive you can do that by checking water-mark in the config (http://documentation.coppermine-gallery.net/en/configuration.htm#admin_watermarking) and then regenerate intermediate pictures in the admintools (http://documentation.coppermine-gallery.net/en/admin-tools.htm#admin_tools_options_rebuild).
Title: Re: watermark old pictures?
Post by: alexandre596 on April 13, 2012, 03:28:11 pm
Quote
When enabling this option, you have to understand that watermarks are not automatically being applied to all files that already exist in your gallery. When enabled, only images that get uploaded from that point on will become watermarked. If you want to apply watermarking to all the images that already existed in your coppermine gallery before you enabled watermarking, take a look at the corresponding section of the admin tools. However, before applying your new watermark permanently to all your images, perform some test uploads first to see if watermarking works as expected for you.

I didn't find that option
and regenerate the intermediate won't help me, since the pictures aren't watermarked =/
Title: Re: watermark old pictures?
Post by: Αndré on April 13, 2012, 03:32:25 pm
Which option in "Update thumbs and/or resized photos" have you tested?
Title: Re: Re: watermark old pictures?
Post by: alexandre596 on April 13, 2012, 03:37:42 pm
Which option in "Update thumbs and/or resized photos" have you tested?

Only resized pictures
Title: Re: watermark old pictures?
Post by: Αndré on April 13, 2012, 03:48:44 pm
I haven't tested that, but a short look at the code may answer that behavior:
Quote
            // Intermediate size
            if ($updatetype == 1 || $updatetype == 2 || $updatetype == 3 || $updatetype == 5) {
                if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {
                    $resize_method = $CONFIG['picture_use'] == "thumb" ? ($CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use']) : $CONFIG['picture_use'];
                    $watermark = ($CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized')) ? 'true' : 'false';
                    if (resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $resize_method, $watermark)) {
                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $normal . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
                    } else {
                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $normal . '</tt></td></tr>';
                    }
                }
            }

This means that Coppermine just updates the intermediate-sized image if it's larger than the config value. IMHO this is wrong, but I haven't checked that in detail yet. In an ideal world Coppermine will check if a specific file (in this case the intermediate-sized image) is needed and exists (depending on your settings it may be possible that such a file wasn't required, but is now or vice versa) and then determines if the file needs to be updated/created/deleted.


However, to solve your issue please open util.php, find
Code: [Select]
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {and replace with
Code: [Select]
if ($CONFIG['make_intermediate']) {
This should apply the watermark to all of your intermediate-sized images, but will also create some intermediate-sized picture while they're not needed (see explanation above).
Title: Re: watermark old pictures?
Post by: alexandre596 on April 13, 2012, 03:52:05 pm
but I want to watermark the full-size picture, not just the intermediate
Title: Re: watermark old pictures?
Post by: Αndré on April 13, 2012, 04:05:27 pm
From what I see in the code it should already work with the full-sized pictures. Just give it a try!
Title: Re: Re: watermark old pictures?
Post by: alexandre596 on April 14, 2012, 12:34:05 am
From what I see in the code it should already work with the full-sized pictures. Just give it a try!

working!!

thank you so much
Title: Re: watermark old pictures?
Post by: Αndré on April 16, 2012, 05:01:00 pm
I think there's a general issue when determining if an intermediate-sized image is needed or not.

During upload we have a similar check
Code: (include/picmgmt.inc.php) [Select]
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
as in the admin tools
Code: (util.php) [Select]
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {
It always checks the biggest size of the picture against the config value, which is wrong, as we have several settings for the resize method. E.g. we decide at several places in the code if we need the full-sized or intermediate-sized picture with code blocks like
Code: [Select]
    // The weird comparision is because only picture_width is stored
    $resize_method = $CONFIG['picture_use'] == "thumb" ? ($CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use']) : $CONFIG['picture_use'];
    if ($resize_method == 'ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width']) {
        $use_intermediate = true;
    } elseif ($resize_method == 'wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']) {
        $use_intermediate = true;
    } elseif ($resize_method == 'any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) {
        $use_intermediate = true;
    } else {
        $use_intermediate = false;
    }

    if ($CONFIG['make_intermediate'] && $use_intermediate) {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
    } else {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
    }


This means we need also adjust the above two code lines accordingly. I'll update the code as soon as possible.
Title: Re: Re: watermark old pictures?
Post by: Αndré on April 20, 2012, 11:51:24 am
Coppermine just updates the intermediate-sized image if it's larger than the config value. IMHO this is wrong, but I haven't checked that in detail yet.
Coppermine's behavior is of course (basically) correct, as the intermediate-sized image won't be used if the full-sized picture doesn't exceed the config value. Merely the check
Code: [Select]
max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width']is wrong, as already said:
It always checks the biggest size of the picture against the config value, which is wrong, as we have several settings for the resize method.


In an ideal world Coppermine will check if a specific file (in this case the intermediate-sized image) is needed and exists (depending on your settings it may be possible that such a file wasn't required, but is now or vice versa) and then determines if the file needs to be updated/created/deleted.


Both has been optimized in SVN revision 8378 (http://coppermine.svn.sourceforge.net/viewvc/coppermine?view=revision&revision=8378). Please check as thoroughly as you can and report any unexpected behavior.