watermark old pictures? watermark old pictures?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

watermark old pictures?

Started by alexandre596, April 13, 2012, 04:36:33 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

alexandre596

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

nickelas

Human

alexandre596

QuoteWhen 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 =/

Αndré

Which option in "Update thumbs and/or resized photos" have you tested?

alexandre596

Quote from: Αndré on April 13, 2012, 03:32:25 PM
Which option in "Update thumbs and/or resized photos" have you tested?

Only resized pictures

Αndré

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
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {
and replace with
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).

alexandre596

but I want to watermark the full-size picture, not just the intermediate

Αndré

From what I see in the code it should already work with the full-sized pictures. Just give it a try!

alexandre596

Quote from: Α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!

working!!

thank you so much

Αndré

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
    // 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.

Αndré

#10
Quote from: Αndré on April 13, 2012, 03:48:44 PM
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
max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width']
is wrong, as already said:
Quote from: Αndré on April 16, 2012, 05:01:00 PM
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.


Quote from: Αndré on April 13, 2012, 03:48:44 PM
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. Please check as thoroughly as you can and report any unexpected behavior.