Advanced search  

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

Pages: [1]   Go Down

Author Topic: watermark old pictures?  (Read 16359 times)

0 Members and 1 Guest are viewing this topic.

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
watermark old pictures?
« 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
Logged

nickelas

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
Re: watermark old pictures?
« Reply #1 on: April 13, 2012, 07:10:36 am »

Logged
Human

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: watermark old pictures?
« Reply #2 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 =/
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: watermark old pictures?
« Reply #3 on: April 13, 2012, 03:32:25 pm »

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

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Re: watermark old pictures?
« Reply #4 on: April 13, 2012, 03:37:42 pm »

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

Only resized pictures
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: watermark old pictures?
« Reply #5 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).
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: watermark old pictures?
« Reply #6 on: April 13, 2012, 03:52:05 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: watermark old pictures?
« Reply #7 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!
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Re: watermark old pictures?
« Reply #8 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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: watermark old pictures?
« Reply #9 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Re: watermark old pictures?
« Reply #10 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. Please check as thoroughly as you can and report any unexpected behavior.
« Last Edit: April 20, 2012, 12:00:11 pm by Αndré »
Logged
Pages: [1]   Go Up
 

Page created in 0.039 seconds with 20 queries.