Problem with watermark Problem with watermark
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Problem with watermark

Started by lunaclems, May 17, 2015, 12:31:05 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

lunaclems

Hello,

I work with Coppermine 1.5.36. I uploaded many pictures (near 7,000) with a watermark. But now I would like to change it or at least remove it. In my config, I removed the watermark but when I go to utility and I try to update the pictures (all, resized or original), the orig_picture.jpg is deleted, and I have the picture.jpg with the watermark not removed.

I would like to replace the "picture.jpg" by the orig_picture.jpg without delete the original picture.

Can someone help me please because it's driving me crazy and I'm loosing a lot of time since about one or two years !

Thanks a lot

For example : http://pictures.katie-melua.org/thumbnails.php?album=637

allvip

#1
The intermediare picture is normal_image.jpg, the thumnails is thumb_image.jpg and the full size (pop up) is image.jpg. orig_image.jpg is created only when you use the watermark. Is a backup for you when you decide not to use the watermark anymore. Once watermak is disabled and you use Admin Tools to update all, the orig_image.jpg gets deleted as is no longer needed. orig_image.jpg is just a copy of image.jpg without watermark that coppermine creates when you use the watermark. Coppermine needs orig_image.jpg to create image.jpg without watermark (when you decide you don't want your images to be watermarked anymore) and then deletes it.

If you decide to use the watermark again then use Admin Tools to update all and the orig_image.jpg will be created again.

To use a custom watermark replace watermark.png from the images folder of your coppermine gallery with your custom watermark image.

lunaclems

Thank you a lot for your answer. I got the point for the first part!

QuoteCoppermine needs orig_image.jpg to create image.jpg without watermark (when you decide you don't want your images to be watermarked anymore) and then deletes it.

But, there's a problem...
When I update the album containing watermarked images, coppermine deletes orig_image.jpg (ok for that) but the image.jpg is still watermarked. For me, it's nonsense...

allvip

#3
Maybe coppermine dev team can help you because it happens to me too.
I want to Config - Watermark images - disable it then Admin Tools - Update thumbs and/or resized photos - Just full sized (if an original copy is available) or Both resized and full sized (if an original copy is available) and that deleted my orig_image.jpg and the image.jpg is still watermarked. I cleared the cokie.

ATTENTION without orig_image.jpg you can not restore the images.
Wait for an answer from coppermine dev team.

lunaclems

Quote from: allvip on May 17, 2015, 08:16:30 PM
Maybe coppermine dev team can help you because it happens to me too.
I want to Config - Watermark images - disable it then Admin Tools - Update thumbs and/or resized photos - Just full sized (if an original copy is available) or Both resized and full sized (if an original copy is available) and that deleted my orig_image.jpg and the image.jpg is still watermarked. I cleared the cokie.

ATTENTION without orig_image.jpg you can not restore the images.
Wait for an answer from coppermine dev team.

Yes, a chance that I kept a copy of original images on my pc... But it's a MESS!!!

Αndré

Have you cleared your browser cache after you used the admin tools? Maybe it's a bug, but I've currently no possibility to test it myself.

allvip

Quote from: Αndré on May 29, 2015, 10:23:11 PM
Have you cleared your browser cache?

I have coppermine on my PC. I opened the image with windows photo gallery. Is watermarked and orig_image.jpg was deleted.
Admin Tools can watermarks unwatermarked images and create orig_image.jpg, but can not unwatermark the images.

Αndré

Confirmed. Patch proposal:
Index: util.php
===================================================================
--- util.php (revision 8783)
+++ util.php (working copy)
@@ -447,14 +447,18 @@
             if ($updatetype == 3 || $updatetype == 4 || $updatetype == 5) {
                 // resize full-sized picture without watermark (will be applied later) if it's bigger than the max width or height for uploaded pictures
                 if (max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) {
-                    if ((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1) || (!USER_IS_ADMIN)) {
-                        // skip resizing for admin if not set to "everyone"
-                        $resize_method = $CONFIG['picture_use'] == "thumb" ? ($CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use']) : $CONFIG['picture_use'];
-                        if (resize_image($work_image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $resize_method, 'false')) {
-                            $imagesize = cpg_getimagesize($image);
-                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $image . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
+                    $resize_method = $CONFIG['picture_use'] == "thumb" ? ($CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use']) : $CONFIG['picture_use'];
+                    if (resize_image($work_image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $resize_method, 'false')) {
+                        $imagesize = cpg_getimagesize($image);
+                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $image . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
+                    } else {
+                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $image . '</tt>!</td></tr>';
+                    }
+                    if (file_exists($orig)) {
+                        if (copy($image, $orig)) {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $orig . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
                         } else {
-                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $image . '</tt>!</td></tr>';
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $orig . '</tt>!</td></tr>';
                         }
                     }
                 }
@@ -491,25 +495,38 @@

             if ($updatetype == 3 || $updatetype == 4 || $updatetype == 5) {
                 if ($CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')) {
-                    // update/create backup of full sized picture if watermark is enabled for full sized pictures
-                    if (copy($image, $orig)) {
-                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $orig . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
+                    if (!file_exists($orig)) {
+                        // create backup of full-sized picture if doesn't exist
+                        if (copy($image, $orig)) {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $orig . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
+                            $backup_file_exists = true;
+                        } else {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $orig . '</tt>!</td></tr>';
+                            $backup_file_exists = false;
+                        }
                     } else {
-                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $orig . '</tt>!</td></tr>';
+                        $backup_file_exists = true;
                     }
-                    // watermark full sized picture
-                    $wm_max_upl_width_height = (max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) ? max($imagesize[0], $imagesize[1]) : $CONFIG['max_upl_width_height']; // use max aspect of original image if it hasn't been resized earlier
-                    if (resize_image($work_image, $image, $wm_max_upl_width_height, $CONFIG['thumb_method'], 'any', 'true')) {
-                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $image . "</tt> " . $lang_util_php['updated_successfully'] . '!' . '</td></tr>';
-                    } else {
-                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $image . '</tt>!</td></tr>';
+                    if ($backup_file_exists) {
+                        // watermark full-sized picture
+                        $wm_max_upl_width_height = (max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) ? max($imagesize[0], $imagesize[1]) : $CONFIG['max_upl_width_height']; // use max aspect of original image if it hasn't been resized earlier
+                        if (resize_image($work_image, $image, $wm_max_upl_width_height, $CONFIG['thumb_method'], 'any', 'true')) {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $image . "</tt> " . $lang_util_php['updated_successfully'] . '!' . '</td></tr>';
+                        } else {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $image . '</tt>!</td></tr>';
+                        }
                     }
                 } elseif (file_exists($orig)) {
-                    // backup picture isn't needed but exists - delete it
-                    if (unlink($orig)) {
-                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . sprintf(str_replace('%s', '<tt>%s</tt>', $lang_util_php['del_orig']), $orig) . '!</td></tr>';
+                    // remove watermark from full-sized picture and delete backup file
+                    if (copy($orig, $image)) {
+                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . '<tt>' . $image . "</tt> " . $lang_util_php['updated_successfully'] . '!</td></tr>';
+                        if (unlink($orig)) {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['ok'] . sprintf(str_replace('%s', '<tt>%s</tt>', $lang_util_php['del_orig']), $orig) . '!</td></tr>';
+                        } else {
+                            echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . sprintf(str_replace('%s', '<tt>%s</tt>', $lang_util_php['del_error']), $orig) . '</td></tr>';
+                        }
                     } else {
-                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . sprintf(str_replace('%s', '<tt>%s</tt>', $lang_util_php['del_error']), $orig) . '</td></tr>';
+                        echo '<tr><td class="'.$tablestyle.'">' . $icon_array['stop'] . $lang_util_php['error_create'] . ': <tt>' . $image . '</tt>!</td></tr>';
                     }
                 }
             }

allvip

I only know to apply a patch manually so I opened util.php, and I start editing. I know the lines marked with - must be deleted and the lines marked with +  must be added.

Watermark and unwatermark images with Admin Tools works great now.



Αndré

Fix committed in SVN revision 8784.