Advanced search  

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]

Pages: 1 2 [3] 4 5 6   Go Down

Author Topic: Permanent Watermark with GD2  (Read 110438 times)

0 Members and 1 Guest are viewing this topic.

uny

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Permanent Watermark with GD2
« Reply #40 on: April 04, 2004, 09:54:32 am »

hi, I just install the Newest MOD. I get the following erro

Code: [Select]
Parse error: parse error, expecting `','' or `';'' in /usr/home/ushuaren/public_html/gallery/config.php on line 297

I appreciate your help!
Logged

uny

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Permanent Watermark with GD2
« Reply #41 on: April 04, 2004, 11:18:16 pm »

Quote from: "uny"
hi, I just install the Newest MOD. I get the following erro

Code: [Select]
Parse error: parse error, expecting `','' or `';'' in /usr/home/ushuaren/public_html/gallery/config.php on line 297

I appreciate your help!


Problem fixed, but I have another two questions:

1. I just noticed that all the sudden, all the YES and NO settings in the Setting can't be chose.

I can't select Neither Yes or No.  it's all Blank.

2. If I add some new images to the album, after I upload them, is there a way to Watermark the NEW images only?

Please let me know the solution if there is any!
Thanks for your MOD!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Permanent Watermark with GD2
« Reply #42 on: April 04, 2004, 11:26:06 pm »

you haven't applied the mod correctly. Undo all your modifications (restore the files from the original coppermine package if necessary) and re-apply the mod.

GauGau
Logged

uny

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Permanent Watermark with GD2
« Reply #43 on: April 04, 2004, 11:31:04 pm »

Quote from: "gaugau"
you haven't applied the mod correctly. Undo all your modifications (restore the files from the original coppermine package if necessary) and re-apply the mod.

GauGau


Thanks GauGau for your reply, but all I did is Upload the PHP adn SQL file that he included in the ZIP file, no Manually edit except Overwrite the file and the SQL command.

any other suggestions?

Thank you!  :)
Logged

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #44 on: April 09, 2004, 02:07:26 pm »

@uny

What is Your Coppermine version?
It should be newest version 1.2.1.

I have now modified 6 coppermine galleries to GD" watermarking with out any problem.

I try do that normal_ image size check to this modification on weekend.
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Permanent Watermark with GD2
« Reply #45 on: April 10, 2004, 07:07:05 am »

@Sammy - the 1.3 release is almost final now - I would suggest whatever you do now onwards should be for version 1.3
Logged
SANIsoft PHP applications for E Biz

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #46 on: April 10, 2004, 10:59:29 pm »

@Tarique

Great to hear about 1.3 version!
I will wait for it.
Logged

photoman13

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 96
Permanent Watermark with GD2
« Reply #47 on: April 11, 2004, 06:38:25 am »

Sammy.. I wanna thank ya again.. your watermarking is working just great for me :):)
Logged

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Thanks Photoman13
« Reply #48 on: April 12, 2004, 10:36:11 pm »

Quote from: "photoman13"
Sammy.. I wanna thank ya again.. your watermarking is working just great for me :):)

You're welcome!
Nice to here that it's working fine for You.
Logged

kudde6

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Permanent Watermark with GD2
« Reply #49 on: April 20, 2004, 07:51:38 pm »

Sammy,

Does this hack also work for version 1.3.0? did you allready test that?

Regards,
K.D.
Logged
Kind regards,
K.D.

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #50 on: April 21, 2004, 08:31:58 am »

@kudde6

I dont know if it will work. I dont have 1.3 yet :(

Last time when I was trying to find 1.3, it was still available for those testers only. Now it seems to be available on public for a month ?  :oops:  :oops:  :oops:


I'll try it.....
Logged

kudde6

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Permanent Watermark with GD2
« Reply #51 on: April 26, 2004, 01:03:16 pm »

HI Sammy,

Any chance that you have tested it ?

Regards,
Kudde6
Logged
Kind regards,
K.D.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Permanent Watermark with GD2
« Reply #52 on: April 26, 2004, 05:41:12 pm »

why don't you test it for the community and let us know your test results ;)

GauGau
Logged

darkcool

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Permanent Watermark with GD2
« Reply #53 on: April 29, 2004, 06:09:01 pm »

this was a great mod I would said.

There is something I would suggest the author of this hack or some one familiar with this hack to think into. When ever the watermark is applied the exif information in the JPEG somehow got delete. I don't know if it possible that the image to have the Exif and still have the watermark on them.


Thanks for this great mod.
Logged

Burpee

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 71
    • Vuurwerklook.com
Re: Permanent Watermark with GD2
« Reply #54 on: April 30, 2004, 01:57:09 pm »

Can you zip up the relevant files and post a link OR sent it to me

I will incorporate it into the main CPG (of course your name will be in the credits)

Do you guys plan on putting it into CPG 1.3 standard?
Would love to see that.
Permanent Watermark with GD2 + CPG 1.3 = my Dream CPG

hoggwild

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Permanent Watermark with GD2
« Reply #55 on: April 30, 2004, 04:55:08 pm »

Great mod Sammy:

Does anyone have this active so that I may see the albums with the watermark?
Logged

Burpee

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 71
    • Vuurwerklook.com
Re: Permanent Watermark with GD2
« Reply #56 on: April 30, 2004, 05:32:10 pm »

Read through all posts first   :D

Sammy's site:
http://www.jarnokalliomaki.com/index_carry.shtml

photoman13

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 96
Re: Permanent Watermark with GD2
« Reply #57 on: May 01, 2004, 04:51:45 am »

Great mod Sammy:

Does anyone have this active so that I may see the albums with the watermark?

It's active on 2 of my sites :)

http://www.ericjon.com/photoserver

&

http://www.richiebrown.net/gallery
Logged

Burpee

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 71
    • Vuurwerklook.com
Re: Permanent Watermark with GD2
« Reply #58 on: May 06, 2004, 01:14:42 pm »

I decided to "modify" this mod so it'll work in CPG 1.3 and my brother helped me fix the "_normal" bug

Permanent Watermark with GD2 MOD


For CPG users who wants to add GD2 watermark function on their gallery.

This MOD uses GD2!

Here is how to mod CPG 1.3 to be able to add watermark automatically on new pics and by choise on all pics in selected album.
This is quite long post, but it takes only about 10 minutes to add this mod

Files that needs to be modified:
Lang/english.php
include/picmgmt.inc.php
util.php
config.php
(and 4 SQL command to execute)


REMEMBER to take backup from all files that You are modifying


1.
Open file Lang/english.php

Find this:
Code: [Select]
'th_wd' => 'Width',
Add this after it
Code: [Select]
               'wm_bottomright' => 'Bottom right',
                'wm_bottomleft' => 'Bottom left',
                'wm_topleftt' => 'Up left',
                'wm_topright' => 'Up Right',
                'wm_both' => 'Both',
                'wm_original' => 'Original',
                'wm_resized' => 'Resized',

Find this:
Code: [Select]
 array('Display notices in debug mode', 'debug_notice', 1), //cpg1.3.0

Add this after it
Code: [Select]

               'Image watermarking',
               array('Watermark Image on upload', 'enable_watermark', 1),
               array('Where to place the watermark', 'where_put_watermark', 11),
               array('which files to watermark', 'which_files_to_watermark', 12),
               array('Which file to use for watermark', 'watermark_file', 0),

             
Find this:
Code: [Select]
 'delete_orphans' => 'Delete orphaned comments (works on all albums)',
Add this a line after it
Code: [Select]
       'watermarks' => 'Add watermaks',
        'watermark_normal' => 'Resized images only',
        'watermark_image' => 'Original sized only',
        'watermark_both' => 'Original and resized images',
        'watermark_wait' => 'Watermarking images...',
        'watermark_continue_wait' => 'Continuing to watermarking originals and/or resized images...',


2.
Open file include/picmgmt.inc.php

Find this:
Code: [Select]
$image_filesize = filesize($image);
Add this before it
Code: [Select]
      //Adds watermarks to new images
       if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original') {
               if (!watermark($image))  //this is for full size image
                       return false;
       }
       if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') {
      if (file_exists($normal) && !watermark($normal))  //this is for intermediate size image
          return false;
       }
               
The following line has been modified to fix the the "_normal bug"
Code: [Select]
      if (file_exists($normal) && !watermark($normal))  //this is for intermediate size image


Find this:
Code: [Select]
?> (or end of picmgmt.inc.php)

Add this before it
Code: [Select]
       /**
         * watermark_image()
         *
         * Create a file containing a watermarked image
         *
         * @param  $src_file the source file
         * @param  $dest_file the destination file
         * @param  $new_size the size of the square within which the new image must fit
         * @param  $method the method used for image resizing  //ainoastaan gd2
         * @return 'true' in case of success
         */
        function watermark($src_file)
        {
            global $CONFIG, $ERROR;
            global $lang_errors;

            $imginfo = getimagesize($src_file);
            if ($imginfo == null)
                return false;
            // GD can only handle JPG & PNG images
            if ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG) {
                $ERROR = $lang_errors['gd_file_type_err'];
                return false;
            }
            // height/width
            $srcWidth = $imginfo[0];
            $srcHeight = $imginfo[1];
         /*   if ($thumb_use == 'ht') {
                $ratio = $srcHeight / $new_size;
            } elseif ($thumb_use == 'wd') {
                $ratio = $srcWidth / $new_size;
            } else {
                $ratio = max($srcWidth, $srcHeight) / $new_size;
            }
            $ratio = max($ratio, 1.0);*/
            $destWidth = $srcWidth; //(int)($srcWidth / $ratio);
            $destHeight = $srcHeight; //(int)($srcHeight / $ratio);

                        $dest_file = $src_file;
            // Method for thumbnails creation
        //    switch ($method) {
        //        case "gd2" :
                    if (!function_exists('imagecreatefromjpeg')) {
                        cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
                    }
                    if (!function_exists('imagecreatetruecolor')) {
                        cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the config page', __FILE__, __LINE__);
                    }
                    if ($imginfo[2] == GIS_JPG)
                        $src_img = imagecreatefromjpeg($src_file);
                    else
                        $src_img = imagecreatefrompng($src_file);
                    if (!$src_img) {
                        $ERROR = $lang_errors['invalid_image'];
                        return false;
                    } //duunataan wesileima
                    $dst_img = imagecreatetruecolor($destWidth, $destHeight);
                                        /*$dst_img =*/   ImageAlphaBlending($dst_img, true) or die ("Could not alpha blend"); // Enable when on GD 2+
                   imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
                                   $logoImage = ImageCreateFromPNG($CONFIG['watermark_file']);
                                        $logoW = ImageSX($logoImage);
                                        $logoH = ImageSY($logoImage);
                                        //where is the watermark displayed...
                                        $pos = $CONFIG['where_put_watermark'];
                                        if ($pos == "topleft") {
                                        $src_x = 5;  
                                        $src_y = 5;
                                        } else if ($pos == "topright") {
                                        $src_x = $srcWidth - ($logoW + 5);
                                        $src_y = 5;
                                        } else if ($pos == "bottomleft") {
                                        $src_x = 5;
                                        $src_y = $srcHeight - ($logoH + 5);
                                        } else if ($pos == "bottomright") {
                                        $src_x = $srcWidth - ($logoW + 5);
                                        $src_y = $srcHeight - ($logoH + 5);
                                        }

                                        ImageCopy($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH); //$dst_x,$dst_y,0,0,$logoW,$logoH);
                    imagejpeg($dst_img, $src_file, $CONFIG['jpeg_qual']);
                    imagedestroy($src_img);
                    imagedestroy($dst_img);
                //    break;
            //}
            // Set mode of uploaded picture
            // We check that the image is valid
            $imginfo = getimagesize($src_file);
            if ($imginfo == null) {
                $ERROR = $lang_errors['resize_failed'];
                @unlink($src_file);
                return false;
            } else {
                return true;
            }
        }



3.
Open File util.php

Find this:
Code: [Select]
function deleteorig()
Add this before it
Code: [Select]
function vesileimaathumbit()   //watermarkthumbs
{
    global $picturetbl, $CONFIG, $lang_util_php;
    $phpself = $_SERVER['PHP_SELF'];
    $albumid = $_POST['albumid'];
    $updatetype = $_POST['updatetype'];
    $numpics = $_POST['numpics'];
    $startpic = 0;
    $startpic = $_POST['startpic'];

    $query = "SELECT * FROM $picturetbl WHERE aid = '$albumid'";
    $result = MYSQL_QUERY($query);
    $totalpics = mysql_numrows($result);

    if ($startpic == 0) {
        // 0 - numpics
        $num = $totalpics;
        // Over picture limit
        if ($totalpics > $numpics) $num = $startpic + $numpics;
    } else {
        // startpic - numpics
        $num = $startpic + $numpics;
        if ($num > $totalpics) $num = $totalpics;
    }

    $i = $startpic;
    while ($i < $num) {
        $image = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . mysql_result($result, $i, "filename");

        if ($updatetype == 0 || $updatetype == 2) {
            $imagesize = getimagesize($image);
            if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'])        {
            $image = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . $CONFIG['normal_pfx'] . mysql_result($result, $i, "filename");
                        }        else        {
            $image = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . mysql_result($result, $i, "filename");
                        }

            if (watermark($image)) {
                print $image .' '. $lang_util_php['updated_succesfully'] . '!<br />'; //$normal .' '. $lang_util_php['updated_succesfully'] . '!<br />';
                my_flush();
            } else {
                print $lang_util_php['error_create'] . ':$image<br />'; //$lang_util_php['error_create'] . ':$normal<br />';
                my_flush();
            }
        }

        if ($updatetype == 1 || $updatetype == 2) {
            $image = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . mysql_result($result, $i, "filename");

            if (watermark($image)) {
                print $image .' '. $lang_util_php['updated_succesfully'] . '!<br />'; //$normal .' '. $lang_util_php['updated_succesfully'] . '!<br />';
                my_flush();
            } else {
                print $lang_util_php['error_create'] . ':$image<br />'; //$lang_util_php['error_create'] . ':$normal<br />';
                my_flush();
            }
        }

        ++$i;
    }
    $startpic = $i;

    if ($startpic < $totalpics) {

        ?>
            <form action=<?php echo $phpself;
        
?>
method="post">
                    <input type="hidden" name="action" value="continuewatermarks" />
                    <input type="hidden" name="numpics" value="<?php echo $numpics?>" />
                    <input type="hidden" name="startpic" value="<?php echo $startpic?>" />
                    <input type="hidden" name="updatetype" value="<?php echo $updatetype?>" />
            <input type="hidden" name="albumid" value="<?php echo $albumid?>" />
            <input type="submit" value="<?php print $lang_util_php['continue'];
        
?>
" class="submit" /></form>
                    <?php
    
}
}  


Find this:
Code: [Select]
updatethumbs();
Add this after it
Code: [Select]

    echo '<br /><a href="' . $phpself . '">' . $lang_util_php['back'] . '</a>';
} else if ($action == 'watermarks') {//tämä
    global $picturetbl, $CONFIG;
    print '<a href="' . $phpself . '">' . $lang_util_php['back'] . '</a><br />';
    print '<h2>' . $lang_util_php['watermark_wait'] . '</h2>';

    vesileimaathumbit();  //watermarkthumbs

    echo '<br /><a href="' . $phpself . '">' . $lang_util_php['back'] . '</a>';
} else if ($action == 'continuewatermarks') {//tämä
    print '<a href="' . $phpself . '">' . $lang_util_php['back'] . '</a><br />';
    print '<h2>' . $lang_util_php['watermark_wait'] . '</h2>';

    vesileimaathumbit();  //watermarkthumbs

Find this:
Code: [Select]
starttable('100%', '<input type="radio" name="action" value="title" id="title" class="nobg"(only part of that line)

Add this before it
Code: [Select]
//This is for watermarking
    starttable('100%', '<input type="radio" name="action" value="watermarks" id="watermarks" class="nobg" /><label for="watermarks" accesskey="w" class="labelradio">' . $lang_util_php['watermarks'] . '</label> (1)');
    print '
<tr><td>
' . $lang_util_php['update_what'] . ' (2):<br />
<input type="radio" name="updatetype" value="0" id="thumb" class="nobg" /><label for="thumb" accesskey="w" class="labelradio">' . $lang_util_php['watermark_normal'] . '</label><br />
<input type="radio" name="updatetype" value="1" id="resized" class="nobg" /><label for="resized" accesskey="r" class="labelradio">' . $lang_util_php['watermark_image'] . '</label><br />
<input type="radio" name="updatetype" value="2" checked="checked" id="all" class="nobg" /><label for="all" accesskey="a" class="labelradio">' . $lang_util_php['watermark_both'] . '</label><br />
' . $lang_util_php['update_number'] . '
<input type="text" name="numpics" value="' . $defpicnum . '" size="5" /><br />
' . $lang_util_php['update_option'] . '<br /><br />
</td></tr>';
    endtable();

    print '<br />';



4.
Open file config.php

Find this:
Code: [Select]
function create_form(&$data)
Add this above it
Code: [Select]
// Added for allowing user to select where to add watermarks on pics...
function form_watermark($text, $name)
{
    global $CONFIG, $lang_config_php;

    $value = $CONFIG[$name];
    $bottomright_selected = ($value == 'bottomright') ? 'selected' : '';
    $bottomleft_selected = ($value == 'bottomleft') ? 'selected' : '';
    $topleftt_selected = ($value == 'topleftt') ? 'selected' : '';
    $topright_selected = ($value == 'topright') ? 'selected' : '';

    echo <<<EOT
        <tr>
            <td class="tableb">
                        $text
        </td>
        <td class="tableb" valign="top">
                        <select name="$name" class="listbox">
                                <option value="bottomright" $bottomright_selected>{$lang_config_php['wm_bottomright']}</option>
                                <option value="bottomleft" $bottomleft_selected>{$lang_config_php['wm_bottomleft']}</option>
                                <option value="topleftt" $topleftt_selected>{$lang_config_php['wm_topleftt']}</option>
                                <option value="topright" $topright_selected>{$lang_config_php['wm_topright']}</option>
                        </select>
                </td>
        </tr>

EOT;
}
// Added for allowing user to select which files to watermark...
function form_watermark2($text, $name)
{
    global $CONFIG, $lang_config_php;

    $value = $CONFIG[$name];
    $both_selected = ($value == 'both') ? 'selected' : '';
    $original_selected = ($value == 'original') ? 'selected' : '';
    $resized_selected = ($value == 'resized') ? 'selected' : '';

    echo <<<EOT
        <tr>
            <td class="tableb">
                        $text
        </td>
        <td class="tableb" valign="top">
                        <select name="$name" class="listbox">
                                <option value="both" $both_selected>{$lang_config_php['wm_both']}</option>
                                <option value="original" $original_selected>{$lang_config_php['wm_original']}</option>
                                <option value="resized" $resized_selected>{$lang_config_php['wm_resized']}</option>
                        </select>
                </td>
        </tr>

EOT;
}


Find this:
Code: [Select]
               case 10 :
                    form_number_dropdown($element[0], $element[1]);
                    break;

Few lines below is
Code: [Select]
die('Invalid action');
Now we need to paste this
Code: [Select]
              //Watermark place
               case 11 :
                   form_watermark($element[0], $element[1]);
                                       break;
               //Which filest to watermark
               case 12 :
                   form_watermark2($element[0], $element[1]);
                                       break;
               case 13 :
                   // do nothing
                   break;
               default:
between them.

After You have done it, it should look like this (I have put couple lines befor and after those lines in this example (hoppe You got it, becouse of My poor english :?
Code: [Select]
               // tabbed display fix
                case 10 :
                    form_number_dropdown($element[0], $element[1]);
                    break;

               //Watermark place
               case 11 :
                   form_watermark($element[0], $element[1]);
                                       break;
               //Which filest to watermark
               case 12 :
                   form_watermark2($element[0], $element[1]);
                                       break;
               case 13 :
                   // do nothing
                   break;
               default:
                    die('Invalid action');
            } // switch
        } else {
            form_label($element);


5.
Then You need to execute theese SQL commands with phpMyAdmin or Webmin, etc.

Code: [Select]
insert into cpg11d_config (name, value) values ('enable_watermark', '1');
insert into cpg11d_config (name, value) values ('where_put_watermark', 'bottomright');
insert into cpg11d_config (name, value) values ('watermark_file', '/your/full/path/to/logo.png');
insert into cpg11d_config (name, value) values ('which_files_to_watermark', 'both');


Thats it. Now You can go to settings and set it up.
Actually You need to go there, before trying to add new pics.
You have to change 'Which file to use for watermark' to point to your own logo.png file that is used as watermark.


This should contain every modification I have made.
« Last Edit: May 06, 2004, 01:21:09 pm by Burpee »
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Re: Permanent Watermark with GD2
« Reply #59 on: May 06, 2004, 01:20:57 pm »

And a zip file with the mod is located at? :D

Great work - thanks
Logged
SANIsoft PHP applications for E Biz
Pages: 1 2 [3] 4 5 6   Go Up
 

Page created in 0.034 seconds with 19 queries.