forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Watermarking & image manipulation => Topic started by: Burpee on June 20, 2004, 11:43:25 pm

Title: Permanent Watermark with GD2
Post by: Burpee on June 20, 2004, 11:43:25 pm
I was unable to modify my original post and I do think that the top post should be the newest version. So I suggest you either split this post off or move it to the first somehow.

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 by Sammy


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 watermarks',
        '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;
            }
        }
Title: Re: Permanent Watermark with GD2
Post by: Burpee on June 20, 2004, 11:43:53 pm
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');

Just to make things entirely clear for beginners:

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', '/*******/**/*********/htdocs/gallery/watermark.png');
insert into cpg11d_config (name, value) values ('which_files_to_watermark', 'both');

the prefix highlighted in red should be edited by the user to make sure it corresponds to their gallery prefix.. latest CPG should have cpg130 as prefix.

the path to the watermark image highlighted in blue has to be the full directory path to the image and not a URL


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.

- Made by Sammy
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: khayman on June 25, 2004, 07:35:11 pm
Hey all. I've added a bit of code to allow you the option to CENTER the watermark on the image. It's not much of a contribution but... it's a contribution nonetheless! ;)

First, make the necessary changes to the files as above.

Further changes need to be made to the following files:

Lang/english.php
include/picmgmt.inc.php
config.php

As above, remember to make backups of all the files you are editing!

1. Open file Lang/english.php

Find this:
Code: [Select]
'wm_topright' => 'Up right',

Add this after it:
Code: [Select]
'wm_centered' => 'Centered',

2. Open file include/picmgmt.inc.php

Find this:
Code: [Select]
} else if ($pos == "bottomright") {
$src_x = $srcWidth - ($logoW + 5);
$src_y = $srcHeight - ($logoH + 5);

Add this after it:
Code: [Select]
} else if ($pos == "centered") {
$src_x = ($srcWidth/2) - ($logoW/2);
$src_y = ($srcHeight/2) - ($logoH/2);

3. Open file config.php

Find this:
Code: [Select]
$bottomleft_selected = ($value == 'bottomleft') ? 'selected' : '';

And add this after it:
Code: [Select]
$centered_selected = ($value == 'centered') ? 'selected' : '';

Find this:
Code: [Select]
<option value="bottomleft" $bottomleft_selected>{$lang_config_php['wm_bottomleft']}</option>

And add this after it:
Code: [Select]
<option value="centered" $centered_selected>{$lang_config_php['wm_centered']}</option>

Note: the above two lines place the CENTERED option on the configuration page in alphabetical order, you can put it in any order within the
Code: [Select]
<select name="$name" class="listbox">
section of the code, as long as it is after the above code and before the
Code: [Select]
</select>
line of code.

That's it! All you have to do now is upload your pages and login as an administrator and update your configuration through the config button.
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: rhydewithdis on June 25, 2004, 10:03:47 pm
First off - thanks for putting this together... maybe someone can assist with this error message I get after when trying to use the watermark feature (everything else worked fine):

PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Joachim Müller on June 26, 2004, 09:18:37 am
check phpinfo to see if you actually have GD (refer to the FAQ for details).

GauGau
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 01, 2004, 11:47:46 am
is there any way to update all images after changing the watermark and the position after a few time?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Joachim Müller on July 01, 2004, 12:51:26 pm
Watermarking is ireversible, that's why this mod is called "permament watermarking". I'm not sure what you mean though.

GauGau
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 01, 2004, 01:42:15 pm
Watermarking is ireversible, that's why this mod is called "permament watermarking". I'm not sure what you mean though.

GauGau

Thank you for replying. What i mean is that if i have apply Watermark A and after a while i decided to change to Watermark B, will the picture that has watermark A able to change to watermark B?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Joachim Müller on July 01, 2004, 03:18:32 pm
no, you can only add watermark B to the already watermarked pic afaik. It's strongly recommended you do watermarking on your client before uploading, will bring much better results and less load on the server. There are some good watermarking apps like PictureShark available for free.

GauGau
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 01, 2004, 03:25:00 pm
no, you can only add watermark B to the already watermarked pic afaik. It's strongly recommended you do watermarking on your client before uploading, will bring much better results and less load on the server. There are some good watermarking apps like PictureShark available for free.

GauGau

Thank you for pointing out such a good software
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: No0dle on July 01, 2004, 04:18:27 pm
How do you do step 5?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 01, 2004, 04:20:17 pm
How do you do step 5?

You have to run the sql query using phpMyAdmin
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: No0dle on July 01, 2004, 04:25:10 pm
Well i get that but how do you do that with phpAdmin what do you have to do there in the admin
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 02, 2004, 10:58:12 am
why i apply the hack and the images come out like that?

http://www.tanfwc.com/beta/albums/userpics/10001/Shannon%20on%20Sandy%232.jpg

i am using a transparent images and the watermark is in PNG format...strange...
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: nyt84 on July 02, 2004, 11:58:20 am
Thanks for the watermark hack..i love it.
For those who want a demo look of the hack, take a look at my gallery
http://gallery.greensg.org

The hack only apply to resized pics only.


Cheers!!
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 05, 2004, 02:32:34 am
why i apply the hack and the images come out like that?

http://www.tanfwc.com/beta/albums/userpics/10001/Shannon%20on%20Sandy%232.jpg

i am using a transparent images and the watermark is in PNG format...strange...

anyone?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: DefenceTalk.com on July 05, 2004, 06:34:31 am
Excellent mod. Thank you!

Anyway to apply the watermark on existing pictures as well as those that are uploaded after this mod was added?

thanks!
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 05, 2004, 02:52:00 pm
Excellent mod. Thank you!

Anyway to apply the watermark on existing pictures as well as those that are uploaded after this mod was added?

thanks!

go to Admin Tools and update those images with watermark...
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: WreckRman2 on July 06, 2004, 10:08:33 am
Thanks for the watermark hack..i love it.
For those who want a demo look of the hack, take a look at my gallery
http://gallery.greensg.org

The hack only apply to resized pics only.


Cheers!!



Hey nyt84, Very nice watermark... I'm no graphic artist would you make me a watermark for a few dollars?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 21, 2004, 12:24:29 pm
Can this work with the lastest CPG 1.3.1?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Joachim Müller on July 21, 2004, 01:37:18 pm
Can this work with the lastest CPG 1.3.1?
why don't you try and give feedback?

GauGau
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 21, 2004, 01:45:05 pm
Can this work with the lastest CPG 1.3.1?
why don't you try and give feedback?

GauGau

Ok. Sure :)
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on July 21, 2004, 04:08:28 pm
It works. Here is the result

http://gallery.tanfwc.com/displayimage.php?album=2&pos=51

GauGau,

Can include a download package for those who do not know how to install?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Soong on July 24, 2004, 06:21:02 pm
Arrrrrrrrrrrgh, can someone help please?

Basically... I did it once, bottom-left but I didn't like the watermark I made. I made another, this time thought I'd have it top-right instead.

The one in the bottom left is still there :( How can I get rid of it?
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Burpee on July 24, 2004, 09:46:12 pm
Arrrrrrrrrrrgh, can someone help please?

Basically... I did it once, bottom-left but I didn't like the watermark I made. I made another, this time thought I'd have it top-right instead.

The one in the bottom left is still there :( How can I get rid of it?
Watermarking is ireversible, that's why this mod is called "permament watermarking". I'm not sure what you mean though.

GauGau

Try reuploading the files


On another note,

Would it be possible to select:
the type of watermark and/or
wether or not you want it watermarked
when uploading?

I personally wouldn't have the slightest clue of how to do this, but it would certainly improve this mod a great deal.
Also, if somebody were to give me pointers and tell me more or less where I should look, I'd be willing to give it a shot with my extremely basic php knowledge
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: photoman13 on August 06, 2004, 02:06:58 pm
awesome watermarking tool.. I gotta say I got it up and installed in less than 10 minutes.


Heck I was updating to 1.3.1 as I was waiting... nothing could have been smoother :)
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: jdk on August 06, 2004, 07:10:27 pm
Is their a way to add option for admins before they approve the pic whether to add watermark or not. So desktop backgrounds don't get water marked.
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: photoman13 on August 06, 2004, 07:24:33 pm
if you put the watermark in the LOWER part of the pic and it's small enough it woul djust get covered by Windows Clock/Toolbar anyways :)

But I know what ya mean.. I already had my wallpapers up.. and I just 'skipped' adding the watermark to that folder.

Maybe in the admin panel you can select what Album Folders get watermarked and which do not. :)

Just an idea :)
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: tanfwc on August 18, 2004, 03:18:14 pm
this hacks works for 1.3.2
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Joachim Müller on August 19, 2004, 09:23:22 am
this hacks works for 1.3.2
sure, that's why the subject says "cpg1.3.x". ;)

GauGau
Title: Re: Permanent Watermark with GD2
Post by: courtneyeliza on September 15, 2004, 06:49:10 pm
HI!

I was wondering if there was a way to center the watermark at the bottom of the photo.
I have it set  up in the left corner, right now.
here's a look: http://www.courtneyelizabeth.com/photos/displayimage.php?album=48&pos=14
I noticed the center in the middle of the image watermark, but that's too far up...so I'd like to have it at the bottom and centered. Thank you for any information! :)

Courtney Elizabeth
http://www.courtneyelizabeth.com
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: Burpee on September 17, 2004, 03:24:03 pm
I hope this works :D

First apply the mod.

Further changes need to be made to the following files:

Lang/english.php
include/picmgmt.inc.php
config.php

As before, remember to make backups of all the files you are editing!

1. Open file Lang/english.php

Find this:
Code: [Select]
'wm_topright' => 'Up right',

Add this after it:
Code: [Select]
'wm_bottomcenter' => 'Centered at bottom',

2. Open file include/picmgmt.inc.php

Find this:
Code: [Select]
} else if ($pos == "bottomright") {
$src_x = $srcWidth - ($logoW + 5);
$src_y = $srcHeight - ($logoH + 5);

Add this after it:
Code: [Select]
} else if ($pos == "bottomcenter") {
$src_x = ($srcWidth/2) - ($logoW/2);
$src_y = $srcHeight - ($logoH + 5);

3. Open file config.php

Find this:
Code: [Select]
$bottomleft_selected = ($value == 'bottomleft') ? 'selected' : '';

And add this after it:
Code: [Select]
$bottemcenter_selected = ($value == 'bottomcenter') ? 'selected' : '';

Find this:
Code: [Select]
<option value="bottomleft" $bottomleft_selected>{$lang_config_php['wm_bottomleft']}</option>

And add this after it:
Code: [Select]
<option value="bottomcenter" $bottomcenter_selected>{$lang_config_php['wm_bottomcenter']}</option>

Note: the above two lines place the Bottom Centered option on the configuration page in alphabetical order, you can put it in any order within the
Code: [Select]
<select name="$name" class="listbox">
section of the code, as long as it is after the above code and before the
Code: [Select]
</select>
line of code.

That's it! All you have to do now is upload your pages and login as an administrator and update your configuration through the config button.
Title: Re: Permanent Watermark with GD2
Post by: Alejandrito on October 13, 2004, 01:35:41 pm
Hi guys!!

Is there a way to watermark images that were uploaded before the watermarking mod?

Have more than 3000 pics and I don't want to upload them again... ??? ::)
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 13, 2004, 04:16:37 pm
It's in Admin Tools / Add watermarks. Select an option and then the album to process.
Title: Re: Permanent Watermark with GD2
Post by: Alejandrito on October 14, 2004, 02:26:34 am
Hi, i don't really see that option, i only have

Quote
Image watermarking
Watermark Image on upload    yes/no
Where to place the watermark    bottom/right
which files to watermark    both
Which file to use for watermark    path

but no have the watermark yet :(
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 14, 2004, 03:09:00 am
Those settings are in Config. Please look at Admin Tools.
Title: Re: Permanent Watermark with GD2
Post by: Alejandrito on October 14, 2004, 01:25:07 pm
Well, in the config page don't have anything like that :(

here is a screenshot
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 14, 2004, 04:22:55 pm
What I was saying was that the settings you were showing were in Config, but you are supposed to look in Admin Tools. It's a separate button. It is not in Config. If you can't find the button, enter this in your addressbar and go: http://AddressToGallery/util.php and substitute your gallery's path accordingly.

You probably don't see the button as Admin Tools because you are using a different language. If you are seeking help from English speakers, please change the language file accordingly so that you can see what they are telling you. You can't expect them to tell you instructions in your language.
Title: Re: Permanent Watermark with GD2
Post by: Alejandrito on October 15, 2004, 06:31:30 pm
What I was saying was that the settings you were showing were in Config, but you are supposed to look in Admin Tools. It's a separate button. It is not in Config. If you can't find the button, enter this in your addressbar and go: http://AddressToGallery/util.php and substitute your gallery's path accordingly.

Greit! your are right, i was looking in Config and not in Admin Conf. About the language, both are the same in spanish as in english. Thanks andsorry for the troubles :)
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 15, 2004, 07:04:51 pm
You're welcome. I'm glad it has been resolved.
Title: Re: Permanent Watermark with GD2
Post by: fedexx on October 15, 2004, 07:57:00 pm
I know the answer that is going to give GauGau to me but of all ways I ask myself in case somebody attempt. Works this add for cpg nuke? ::)
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 15, 2004, 08:00:41 pm
If you know the answer, why do you ask? Try out the mod for yourself. People are here because they are using and developing the standalone version of Coppermine. You expect them to test it out on cpgnuke? Also, cpgnuke does have its own forums.
Title: Re: Permanent Watermark with GD2
Post by: fedexx on October 15, 2004, 08:20:29 pm
ok thanks to be SO amiable, TranzNDance
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 15, 2004, 08:49:22 pm
You're welcome. Thank you for being so considerate of our time.
Title: Re: Permanent Watermark with GD2
Post by: fedexx on October 15, 2004, 09:06:48 pm
If I consider its time coverall yours. who must of be SO imporatant... excuse me nonwise that spoke with a so huge man...  :-\\ ;D
Title: Re: Permanent Watermark with GD2
Post by: maria on October 16, 2004, 07:02:49 pm
Hi! I need obtain that watermark is added to the photos that I raise with of the batch, they excuse if I am annoying but I am new in this forum and I need do this for my CPG. Thanks
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 16, 2004, 07:07:29 pm
Maria, I'm sorry, but what is your question? The instructions for the mod are on page 1 of this thread.
Title: Re: Permanent Watermark with GD2
Post by: mrsandman on October 17, 2004, 06:12:06 pm
ive installed the hack bu dont have a watermark.png. ok i dont know how to create my watermark.png?? i just want a text, simple tutorial please.
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 17, 2004, 06:17:52 pm
It would depend on what imaging software you have. You could do a search in a serach engine for something like "create watermark photoshop" if you have Photoshop.
Title: Re: Permanent Watermark with GD2
Post by: mrsandman on October 17, 2004, 06:22:31 pm
i dont use an imaging software. i just upload off my camera. cant i use php and gd to do this?
Title: Re: Permanent Watermark with GD2
Post by: Burpee on October 18, 2004, 01:54:15 am
Perhaps http://www.cooltext.com/ could be a solution for you... try rendering it as a .PNG with transparency...
Title: Re: Permanent Watermark with GD2
Post by: mrsandman on October 18, 2004, 02:02:45 am
thanks i will give it a go
Title: Re: Permanent Watermark with GD2
Post by: maria on October 18, 2004, 05:34:52 am
TranzNDance thanks already reesolve my problem, but i have a new one,: ( but I am going to postear it in 1,2 forum CPG Standalone Support because it does not go with this subject
bye !
Title: Re: Permanent Watermark with GD2
Post by: yemgi on October 21, 2004, 02:33:59 pm
Hi all,

I have just installed this mod but I can't get it work :(

When I try watermarking existing images, here is what I get :
Code: [Select]
Warning: imagesx(): supplied argument is not a valid Image resource in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 323

Warning: imagejpeg(): Unable to open 'albums/divers/banni_re_internet.jpg' for writing in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 324
albums/divers/banni_re_internet.jpg modifié avec succès!

In the Configuration Menu, watermarking remain on Off and the watermak path is empty, I looked int the database and the values are OK.

Have I done something wrong ?

Edit :
I am runinng CPG1.3.2 with IPB2.0 bridge
GD2 is enabled
Title: Re: Permanent Watermark with GD2
Post by: DaRichMan on October 21, 2004, 03:19:20 pm
Hi all,

I have just installed this mod but I can't get it work :(

When I try watermarking existing images, here is what I get :
Code: [Select]
Warning: imagesx(): supplied argument is not a valid Image resource in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 323

Warning: imagejpeg(): Unable to open 'albums/divers/banni_re_internet.jpg' for writing in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 324
albums/divers/banni_re_internet.jpg modifié avec succès!

In the Configuration Menu, watermarking remain on Off and the watermak path is empty, I looked int the database and the values are OK.

Have I done something wrong ?

Edit :
I am runinng CPG1.3.2 with IPB2.0 bridge
GD2 is enabled

I've got the same errors. Anyone?
Title: Re: Permanent Watermark with GD2
Post by: alfisti.net on October 22, 2004, 12:49:30 am
Thanks Burpee :)
I love it and all work fine with photos, but I have problems with uploading videos.
Setting videos to the database work only when I disable the watermarking.
Have I made a mistake or this this "normal".
If it is normal, is there a way to ask for the type of file in the script so that videos don´t get a watermark and make trouble?

Regards
André
Title: Re: Permanent Watermark with GD2
Post by: MikaK on October 22, 2004, 06:42:57 am
This is a very well written mod.

A small glitch however: If currently used when also uploading video files, the infamous "File could not be placed" when trying to upload videos is created if the watermarking is used for the originals.

Would there be any way to get around this problem? Somehow selectively only to watermark images but not videos (naturally ;D - but how ???)

Best regards,
-MikaK
Title: Re: Permanent Watermark with GD2
Post by: DaRichMan on October 23, 2004, 04:27:09 pm
Still getting errors like:
Warning: imagesy(): supplied argument is not a valid Image resource in ../include/picmgmt.inc.php

Does anyone know what's wrong?
Title: Re: Permanent Watermark with GD2
Post by: yemgi on October 24, 2004, 12:18:12 am
I found one of my errors : my gallery was not using the database I thought  ??? ::)
The configuration menu is now OK
The watermaking is now OK for the uploads
Only problem I still have is when trying to watermark existing pics, it doesn't work and I have the following error :
Code: [Select]
Warning: imagejpeg(): Unable to open 'albums/divers/banni_re_internet.jpg' for writing in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 324
albums/divers/banni_re_internet.jpg modifié avec succès!

Warning: imagejpeg(): Unable to open 'albums/divers/banni_re_internet.jpg' for writing in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 324
albums/divers/banni_re_internet.jpg modifié avec succès!
Title: Re: Permanent Watermark with GD2
Post by: tanfwc on October 24, 2004, 04:50:22 am
I found one of my errors : my gallery was not using the database I thought ??? ::)
The configuration menu is now OK
The watermaking is now OK for the uploads
Only problem I still have is when trying to watermark existing pics, it doesn't work and I have the following error :
Code: [Select]
Warning: imagejpeg(): Unable to open 'albums/divers/banni_re_internet.jpg' for writing in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 324
albums/divers/banni_re_internet.jpg modifié avec succès!

Warning: imagejpeg(): Unable to open 'albums/divers/banni_re_internet.jpg' for writing in /home/httpd/vhosts/bahamutcars.com/httpdocs/subdomains/galleries/include/picmgmt.inc.php on line 324
albums/divers/banni_re_internet.jpg modifié avec succès!

What is the correct permission for "albums/divers"? It can't open up for writing. Make sure it is chmod to 777.
Title: Re: Permanent Watermark with GD2
Post by: yemgi on October 24, 2004, 03:26:30 pm
Thanks for pointing this out :)

The directories were in 777 but the ffiles I uploaded by FTP were in 644 mod while the normally uploaded ones are 666. I chmoded all files as 666 and all works fine now :)

Thanks a lot for your help and this great mod :)
Title: Re: Permanent Watermark with GD2
Post by: Boegh on October 24, 2004, 07:08:19 pm
Burpee > Totally great hack/add-on!!
I love it, keep up the great work!

GauGau > Is it possible to add this hack permanently to future releases of CPG?
So that we do not have to implement it manually in new versions?

// Greetings Boegh -  Denmark
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on October 25, 2004, 07:50:36 am
This will only be included if someone comes up with a hack that makes the mod work both for users running GD and ImageMagick.

Joachim
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 25, 2004, 07:55:34 am
PHP lets us place text, shapes, lines on top of image files on-the-fly, kind of like your IP on the AV trick. Is it possible to put image files on top of image files? Would that function depend on server settings? Would it be too resource intensive if it's done on-the-fly?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on October 25, 2004, 08:16:04 am
Would it be too resource intensive if it's done on-the-fly?
Yes, that's what all those watermark mods available do. They can only be used on sites with nearly no traffic, on larger sites they will bring the server down (or at least, they will get you in trouble with your webhost).
My avatar is just some "proof of concept" thing that can only be done because my personal page if a low traffic site and the image I use is rather small. Doing this stunt "On the fly" with a full-size pic would be way to resources-consuming. Another drawback of the method I use for my avatar is that it relies on GD2, it won't work with GD1 nor ImageMagick (that's why I haven't started coding it for cpg).

Joachim
Title: Re: Permanent Watermark with GD2
Post by: DaRichMan on October 25, 2004, 08:18:00 am
Still getting errors like:
Warning: imagesy(): supplied argument is not a valid Image resource in ../include/picmgmt.inc.php

Does anyone know what's wrong?

Sorry for this message again, but doesn't anyone know?
Please  :\'(
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on October 25, 2004, 08:50:07 am
you probably didn't apply the hack properly. Undo your modifications and start over.

Joachim
Title: Re: Permanent Watermark with GD2
Post by: DaRichMan on October 25, 2004, 11:32:52 am
How should i name the watermark image? What kind of file (jpeg, png ???) ? Where should this file be places?

Thanks
Title: Re: Permanent Watermark with GD2
Post by: kegobeer on October 25, 2004, 01:26:46 pm
@DaRichMan: Read the entire thread.
Title: Re: [CPG1.3.x]: Permanent Watermark with GD2
Post by: eliteracer on October 31, 2004, 09:53:44 pm
Please, can you post a download package!

Thanks!

It works. Here is the result

http://gallery.tanfwc.com/displayimage.php?album=2&pos=51

GauGau,

Can include a download package for those who do not know how to install?
Title: Re: Permanent Watermark with GD2
Post by: Burpee on November 10, 2004, 12:40:42 am
Burpee > Totally great hack/add-on!!
I love it, keep up the great work!

Don't thank me, thank Sammy! He's the one that made the mod, I just fixed some minor errors that were in it...
Title: Re: Permanent Watermark with GD2
Post by: rob2k4life on November 11, 2004, 03:51:55 am
I got it to work but it is only watermarking the resized image, but I have it on watermark "both" anyone know whats wrong with mine?
Title: Re: Permanent Watermark with GD2
Post by: Sammy on November 19, 2004, 12:02:43 am
Hello All

First I have to say Thanks for Burpee for making those "minor fixes" and for porting this mod for use with 1.3x.
Thanks also for Burbee's brother for co working on it.
I have been working quite lot for a some time ( 1/2 year ) now. Gladly when I came here to see how Coppermine is growing, almost first I bump on Burpees thread :)

Anyway, I now just want to say thank's  :D
Title: Re: Permanent Watermark with GD2
Post by: Burpee on November 20, 2004, 07:01:38 pm
Hey Sammy :D
Nice seeing you back here :)
Title: Re: Permanent Watermark with GD2
Post by: Binks on December 05, 2004, 12:41:05 pm
There is bug in this mod(so i think). I did exactly as sammy instructed and when i do "batch file adding" some pictures are watermarked and some of them not. Randomly. As i've notice, watermark works, in "batch adding", only on pictures that are bigger then dimentions of intermediat picture. When file(picture) is exact or smaller dimentions, the watermark isn't putted on a picture.
As i said, it happends only when i want to do "catch file adding", but i think that this is big problem, couse when i have 300pictures to add, i would like to use "batch adding"...


Binks
Title: Re: Permanent Watermark with GD2
Post by: Sammy on December 08, 2004, 09:54:58 pm
Hello Binks

If I remember correctly, it compares imagesizes just as You say. It Does not add watermark on images, that are smaler than intermediate image size declared in settings page for intermediate imeges.
Title: Watermark: How do I display the pictures address on every uploaded photo?
Post by: kleppen on December 17, 2004, 09:10:41 pm
hello !
I wonder if its possible to fix that if a user uploads a photo or a picture the
picture adress is displayed on the uploaded photo..
and if its ok and possible: shorter url:
like
http://domain.com/?pic=2212343424324243
Title: Re: Permanent Watermark with GD2
Post by: Tranz on December 17, 2004, 09:58:50 pm
I suppose it's possible using ImageTTFText() or ImageString(). I'm using both of them to display dynamic text on my avatar. I output my images temporarily to the browser only. You should output actual files to minimise resource use.

PS. Don't send unsolicited PMs to dev team members.
Title: Re: Permanent Watermark with GD2
Post by: Hein Traag on December 24, 2004, 07:23:49 pm
Busy adding this mod to pictures.scoutlink.net atm and found a teenyweeny typo

-->typo (Watermarks)       '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...',
Title: Re: Permanent Watermark with GD2
Post by: Tranz on December 24, 2004, 07:48:36 pm
Oh yeah, I noticed that. I have edited the first post. :)
Title: Re: Permanent Watermark with GD2
Post by: Hein Traag on December 24, 2004, 08:21:52 pm
Right i applied all code changes, without wrecking the cpg (hooray for me) and now i wanted to apply the watermarking to
some albums as per test.

Went to Admin Tools and selected Add Watermarking, choosing both resized and original pictures.
Selected the album to apply the watermarking to and hit Submit. After some thinking on the serverside is displays a page which says all pics were update succesfully.

All ok so far.

Except for one thing. I don't see the watermarking appear on any of the pictures. I tried setting the intermediate picture size to a lower size, following the advice Sammy gave but with no result. The path to the images is in order, goes from /public_html/ all the way to logo.png so that should not be the problem.

Anybody got an idea where i might look for the answer ?

Thanks
Hein
Title: Re: Permanent Watermark with GD2
Post by: Tranz on December 24, 2004, 08:23:05 pm
Did you go through the error logs to make sure that the file path is interpreted correctly?
Title: Re: Permanent Watermark with GD2
Post by: Hein Traag on December 24, 2004, 08:35:46 pm
*removed debug list

If i read the whole thread correctly this should also work on pics that were already uploaded.

Has to be something to do with the path to logo.png

In a nutshell: Admin Tools - Add Watermarking (choose resized and normal) - choose album - hit Submit
That should add watermarking to a album that already was in the gallery right ?
Assuming the path to the images was correct in both config and mysql.

Tried it by uploading a picture thru upload.php.. again no result.

Past my bedtime and lack of coffee.. If someone can point me in the right direction its appreciated. For now it's bye bye  ;)
Title: Re: Permanent Watermark with GD2
Post by: Tranz on December 24, 2004, 11:02:37 pm
It should work on existing photos.

(This is when it is difficult to help people with different webhosts. )

For example, my full path to the .png is:
/home/username/public_html/galleryname/blahblah

If you're unsure of the absolute path, you should ask your host.
Title: Re: Permanent Watermark with GD2
Post by: Hein Traag on December 25, 2004, 10:57:35 am
Thanks TranzNDance that did it. Forgot to type full path  :o.

I did find a other option to add watermarking to pictures. I did some testing with WebDrive (http://www.webdrive.com/) which connects a ftp folder as a normal folder under Windows.
And then I used FastStone resizer/renamer to add watermarking. One drawback to some maybe that you need a decent internet connection.

Thanks for the help!
Title: Re: Permanent Watermark with GD2
Post by: peezy on January 02, 2005, 07:06:14 am
Ok, i've tried to re-install this mod like 5 times from scratch and have been working on it for a while and keep getting an error.

Code: [Select]
Warning: imagecreatefrompng(/your/full/path/to/logo.png): failed to open stream: No such file or directory in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 303

Warning: imagesx(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 304

Warning: imagesy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 305

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 325
albums/userpics/10001/photocart.jpg updated succesfully!

Can anybody help me? anyone know where this problem might be?
Title: Re: Permanent Watermark with GD2
Post by: Tranz on January 02, 2005, 07:13:01 am
In Config, did you put the full path to the watermark file?

If this was in the actual error message (and you hadn't edited it when posting), then it is incorrect:
/your/full/path/to/logo.png

You can get the full path info in the rest of the error message which shows where the files are located.
Title: Re: Permanent Watermark with GD2
Post by: peezy on January 02, 2005, 07:22:28 am
nope, that didn't work either now it says

Code: [Select]
Watermarking images...

Warning: imagecreatefrompng(/home/club303/public_html/fp/watermark.png): failed to open stream: No such file or directory in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 303

Warning: imagesx(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 304

Warning: imagesy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 305

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 325
albums/userpics/10001/photocart.jpg updated succesfully!

it says that for each picture in the album
Title: Re: Permanent Watermark with GD2
Post by: Tranz on January 02, 2005, 07:25:36 am
Is this correct:
/home/club303/public_html/fp/watermark.png

The rest of the error message say your files are in
/home/club303/public_html/fp-photo/

If you try to access the watermark file via browser, does it work? So you should be able to see it http://yourdomain.tld/fp/watermark.png if
/home/club303/public_html/fp/watermark.png
is correct.
Title: Re: Permanent Watermark with GD2
Post by: peezy on January 02, 2005, 07:38:12 am
aww man.... the file was kinda right, i didn't realize photoshop saved it watermark.PNG not watermark.png 

i hate it when it's case sensative!

Thanks for the help!
Title: Re: Permanent Watermark with GD2
Post by: RGSMDNR on January 06, 2005, 05:28:20 am
im getting this error...

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2412 bytes) in /home/virtual/site430/fst/var/www/html/coppermine/include/picmgmt.inc.php on line 226

it worked once (kinda, the watermark was fuzzy) but now i get that..

thoughts?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on January 07, 2005, 09:01:19 am
http://forum.coppermine-gallery.net/index.php?topic=5843.0
Title: Re: Permanent Watermark with GD2
Post by: RGSMDNR on January 07, 2005, 05:05:41 pm
ok, well it looks like ill have to live with it for now and get my users to upload non hi res pics.

now where in the code does it say how big the watermark image can be? is there a limit?

also on smaller pics, will it resize the watermark to fit?
Title: Re: Permanent Watermark with GD2
Post by: partypics on January 09, 2005, 04:51:25 pm
Hello!
I used this mod and added an ability to choose between image watermark and a simple text watermark.
Text watermark may contain username and look like that, for example www.somesite.com/username/

This instruction is only valid if you have applied this mod before (cause it's not the full instruction).
In your lang file add this to Watermark section:

Code: [Select]
  array('Use text watermark instead of image', 'watermark_use_text', 1),
  array('Text to use for a watermark', 'watermark_text_pattern', 0),
  array('Watermark text color (r,g,b)', 'watermark_text_color', 0),
  array('Watermark text font size (points)', 'watermark_text_size', 0),

run this in phpMyAdmin or similar:

Code: [Select]
INSERT INTO `cpg132_config` VALUES ('watermark_text_pattern', 'test string');
INSERT INTO `cpg132_config` VALUES ('watermark_use_text', '0');
INSERT INTO `cpg132_config` VALUES ('watermark_text_color', '255,255,255');
INSERT INTO `cpg132_config` VALUES ('watermark_text_size', '10');

edit picmgmt.php , find
Code: [Select]
function watermark($src_file)and replace the whole function (not just that line) with this:

Code: [Select]
function watermark($src_file) {

global $CONFIG, $ERROR, $USER_DATA;
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];

$destWidth = $srcWidth; //(int)($srcWidth / $ratio);
$destHeight = $srcHeight; //(int)($srcHeight / $ratio);

$dest_file = $src_file;

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;
}
$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);

//where is the watermark displayed...
$pos = $CONFIG['where_put_watermark'];
if (!$CONFIG['watermark_use_text'])  // if we are using image as a watermark
{
$logoImage = ImageCreateFromPNG($CONFIG['watermark_file']);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);

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);
}
else // using text as watermark
{
if ($pos == "topleft")
{
$src_x = 5;
$src_y = 10;
}
else if ($pos == "topright")
{
$src_x = $srcWidth - 100;
$src_y = 10;
}
else if ($pos == "bottomleft")
{
$src_x = 5;
$src_y = $srcHeight - 5;
}
    else if ($pos == "bottomright")
{
$src_x = $srcWidth - 100;
$src_y = $srcHeight - 5;
}


$color_arr = explode(',',$CONFIG['watermark_text_color']);
$color = imagecolorallocate($dst_img, $color_arr[0], $color_arr[1], $color_arr[2]);
$wat_text = eval("return (\"$CONFIG[watermark_text_pattern]\");");
imagettftext($dst_img,$CONFIG['watermark_text_size'],0,$src_x,$src_y,$color,'path/to/your/font/arial.ttf', $wat_text) or die ('Error - could not add a text watermark!');

}

         
imagejpeg($dst_img, $src_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);

// 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;
}

}

Where "path/to/your/font/" is an absolute path to .ttf file on your server.
Now go to the config page and switch the option "use text watermark instead of image".

With this modification you are able to use such string in the "watermark text" field
Code: [Select]
www.$_SERVER[HTTP_HOST]/$USER_DATA[user_name]/and the watermark text will be something like
Code: [Select]
www.somesite.com/username/
where username is the name of the pic's uploader. You can use other global variables as well.
It may be not safe, because it uses eval() function, so, don't use it if you are not the only one admin of the gallery.
To avoid eval() the string can be hardcoded to the script, or you can delete eval()  if you are not going to use variables in your watermark.
If you place text watermark on the right side of an image - correct the line
Code: [Select]
else if ($pos == "topright")
{
$src_x = $srcWidth - 100;
$src_y = 10;
}

and change 100 to your suitable number, depending of your text length (and font size). But it's more convenient to place  variable-length text watermark on the left side of an image.
Again - it uses eval() and has no validation of values you enter in config page - use it at your own risk (or modify to be more safe  ;) )

Hope I didn't forget anything!

PS: found a typo(?) - in original code "topleft" is called "topleftt" (double "t") in lang and config files..
Title: Re: Permanent Watermark with GD2
Post by: gab696 on January 19, 2005, 10:41:00 pm
I have tried to install this Hack but when i try to change the watermarking in the config pannel.
The changes are not saved.  ???
I'am not sure to have correctly inserted the 4 lines in my base and the config.php (i'am a newbie  :-\\ )

Title: Re: Permanent Watermark with GD2
Post by: partypics on January 19, 2005, 10:53:16 pm
This will work only if you have correctly applied the first part - image watermark. Try phpMyAdmin to insert sql statements.
Title: Re: Permanent Watermark with GD2
Post by: biootik on January 21, 2005, 12:12:21 am
hi all !

i've just installed "permanent Watermaking" on my 1.3.0 coppermine site ..

it works well by upload and by the util page too , but only on resized pics, on original pics it doesn't work at all .
well, it says that pics have been watermarked , but they are not.

any of u got this matter ?  ??? ??? ???

ps:i supposed it was my code copy which was bad  , but i've checked 3 times the code , and i did it well .

tks for answering..

bioo
Title: Re: Permanent Watermark with GD2
Post by: romans815 on February 12, 2005, 03:01:45 am
Am looking for any and all advise. I added everything and get this:

>>>>>>>>>>>>>>>>>>>>>>>>IN THE UPLOAD AND ASSIGN TO ALBUM SECTION

Warning: imagecreatefrompng(home/champ1/public_html/gallery/images/watermark.png): failed to open stream: No such file or directory in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 323

Warning: imagecreatefrompng(home/champ1/public_html/gallery/images/watermark.png): failed to open stream: No such file or directory in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 323


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>IN THE ADMIN SECTION

Watermarking images...

Warning: imagecreatefrompng(home/champ1/public_html/gallery/images/watermark.png): failed to open stream: No such file or directory in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 323
albums/userpics/10001/normal_DSC00988.jpg updated succesfully!
Title: Re: Permanent Watermark with GD2
Post by: PBas on February 16, 2005, 10:59:36 pm
Well.... i've aplied the watermarking mod and it works perfectly. (had one error ... path ... but that was my problem, not the MOD)

The question:
Is it possible to have a smaller watermark pic for normal size pics? or working with %... i don't know.


Thanks!

(coppermine gallery since v1.2 - 1 year long - now updated to 1.3.2)
Title: Re: Permanent Watermark with GD2
Post by: bibendum on February 19, 2005, 09:06:36 pm
Hi

Thanks for this wonderfull mod.

Is it possible to select wich pictures you want to apply Watermark with admin/utils ?

Because some of my pictures are copyrighted by their owrners and i don't want to apply my copyright !!!!

Even with pictures to be validated by admin, select yes/no to apply Watermark.

Thanks a lot



Title: Re: Permanent Watermark with GD2
Post by: opulence on February 20, 2005, 10:21:19 pm
I'd like to use Burpee's mod of this mod, for CPG 1.3... however I'm wondering where the watermark will appear?  and how to set it so that it will appear at bottom - 10px left - 10px  (in the bottom left corner with a 10 pixel offset).
Title: Re: Permanent Watermark with GD2
Post by: davidshook on February 22, 2005, 02:52:20 am
I am sorry if this is answered somewhere in this thread allerady.
How exactly does this MOD work:
1) do all the batch uploaded pictures get watermarked?
-- or, do I get to chose if batch uploaded pictures get watermarked?

2)  do individual uploaded pictures get water marked?
-- do users/members (as opposed to admin level) have any control over the water marking process in this case.

3) what happens when a user uploads video, mp3, zip, pdf file?
-- does the upload faile?
-- does the file become unreadable?


The reason I am asking this is because I am designing a site that will have  a gallery that allows loged-in members to upload there own pictures/videos/documents. I want to have a watermark on the pictures that the users upload. The user should not be able to upload a picture without a water mark (although it is ok if they have a choice where to place the watermark on the picture)

The rest of the galleries are not for uploads by users. For these galleries I do the batch uploading and the pictures are already watermarked on my desktop pc prior to upload.

So, to some it up: all pictures that are uploaded via http/form need to be watermarked.
Batch files should not be watermarked.
Non-picture files should not be a problem (since I do not limit the file type to be uploaded)


I also think that anyone that thinks about using water marking should have these answers before going through the work of installing and testing the MOD's.

Please help, thank's in advance



Title: Re: Permanent Watermark with GD2
Post by: davidshook on February 24, 2005, 04:58:12 am
hello, help anyone?
Title: Re: Permanent Watermark with GD2
Post by: kegobeer on February 24, 2005, 06:07:59 am
Again, have you reviewed the entire thread?  Please don't post identical replies in three different threads.
Title: Re: Permanent Watermark with GD2
Post by: davidshook on February 24, 2005, 09:17:01 pm
Again, have you reviewed the entire thread?  Please don't post identical replies in three different threads.

No disrespect, but if I would have gotten the answer to my question(s) I would have not posted in 3 different threads. I sincerely appreciate the effort and hard work put into these MOD's, but I am not sure as to the exact way to use them. I read the posts here and did not get a streight answer. I also noticed a few scatered posts that had similar questions... I could not find the answers to those posts either.

I would thinkk that it would be nice to have these answers all collected in one post and not have to search for them repeatedly in different posts. It just makes sense to explain how a script work rather than having to go through the instalation and searching process in each thread.

Hopfully, you won't take offence and if you can atleast point me to the correct post to get the answers to my questions.

Thank you
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on February 25, 2005, 09:23:07 am
The mods are all user contributions. You can't expect us (the dev team) to test them all, compare them to each other and write a summary on them. A thread lebelled "watermark with GD" is of course something different than "watermark with ImageMagick". As you can only use one at a time, and you should know which image library you use on your server, there's little point in us holding your hand to explain the fundamental differences between GD and ImageMagick - this has been covered elsewhere, you can't expect us to repeat a lengthy explanation on each thread that deals with those image libraries.
The same thing applies to the other differences between those watermarking hacks: if you had read all of those threads you were replying to, you would have found out that the devs disapprove of on-the-fly watermarking (read up the discussion why this is so), so we don't recommend using a watermarking hack at all. You can't expect us to support stuff that we don't recommend using at all.

Joachim
Title: Re: Permanent Watermark with GD2
Post by: davidshook on February 26, 2005, 04:33:01 am
Ok, to answer my own question:
1. yes, batch uploaded pictures get watermarked. You get to choose where to place the watermark (up left/right or  down left/right, there is an extra MOD somewhere on this thread that also allows for centering the watermark, but I have not tried it).
- there is an option (in the 'config' section) that suppose to allow you to choose if you want the uploaded files to be watermarked.
IT DOES NOT WORK FOR ME - all my files get watermarked even if I choose the no watermark option.. Possibly I did not install the script correctly!? (one way to by pass this problem is by using the option that only watermarks the resized pictures... I don't use any resized pictures and therefore non of my uploaded pictures will get watermarked when I choose this option ;)

2. Individually uploaded pictures (using the 'Upload file' option) also get watermarked in the same manner as the batch uploaded pictures get watermarked..
-- users/members (other than the administrator) do not have control over the watermarking process.
 
3. So far I CAN NOT place succesfully a non-picture file!!!
I am able to upload the file and get to the page that askes for a title, description, and keywords, after that I get the error: "The previous file could not be placed."
I tried this it with MPEG and mp3 files a few times and got the same error in all my attempts.
- somebody already mentioned this error on this thread, but no one posted a solution.


Hope that this helps anyone considering this MOD and it would be great if someone can post an advice regarding #1 and #3

Thanks
Title: Re: Permanent Watermark with GD2
Post by: yaakoob on February 27, 2005, 11:12:36 pm
I have similar problem with the video upload. So, for now, I am using 2 different CM instelations on my domain/server. One for the pic's and one for videos... kind-of and overkill!

Any help?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on February 28, 2005, 07:45:22 am
hm, hate to repeat, but anyway: using watermarking isn't recommended anyway, as it will put an enormous strain on server load. Your webhost will certainly prefer it if you don't use it at all, at least if you're getting a high traffic volume (and even serve videos). Instead of using watermarking (and having the need for two separate installs), it's recommended to watermark pics permanently (before upload).

Joachim
Title: Re: Permanent Watermark with GD2
Post by: thejinx0r on March 03, 2005, 09:52:19 pm
How do you execute sql commands in php ?  :-[

it's been asked a few times, but never answered :(

also, is there a way to say where to put the watermarks exactly ?
like 50px from the right and 50 pixel from the bottom?
or only the default ones?
Title: Re: Permanent Watermark with GD2
Post by: Nibbler on March 04, 2005, 01:21:56 pm
SQL commands can be run with a db admin tool such as phpmyadmin.

You can set the $src_x and $src_y to whatever you like - just change the code.
Title: Re: Permanent Watermark with GD2
Post by: thejinx0r on March 04, 2005, 01:46:10 pm
SQL commands can be run with a db admin tool such as phpmyadmin.

You can set the $src_x and $src_y to whatever you like - just change the code.

i have php my admin...

but i dont know how to execute them with it...
Title: Re: Permanent Watermark with GD2
Post by: squrban on March 04, 2005, 02:35:25 pm
Hi
Can this work with CPG 1.3.2 ?
I try & try but nothing   ???

any bady help me>>>
Title: Re: Permanent Watermark with GD2
Post by: Nibbler on March 04, 2005, 02:42:58 pm
squrban - read the thread - first post
thejinx0r - if you don't know how to use something, read the manual that comes with it.
Title: Re: Permanent Watermark with GD2
Post by: thejinx0r on March 04, 2005, 03:52:17 pm
You can set the $src_x and $src_y to whatever you like - just change the code.

manual wasn't very helpful...
but i guess i figured it out.

oh well,
is there a way to have to different position? one for the normal and one for resized?
or am i going to have to figure that out for my self?

Title: Re: Permanent Watermark with GD2
Post by: Nibbler on March 04, 2005, 04:02:47 pm
That's possible. You either need to code the changes yourself or wait for someone to post it for you.
Title: Re: Permanent Watermark with GD2
Post by: thejinx0r on March 04, 2005, 04:13:23 pm
one last question and i'll be good for a while.

what exactly is the resized picture?
is it a picture that someone made smaller/bigger after uploading?

well if that's what it is,

then what do you call  the picture? the sort of smaller one that you have to click to make it bigger?

http://thejinx0r.l2p.net/RSP/displayimage.php?album=1&pos=0
theres no water mark on it,
but when you click on it, the water mark is there.

and thanks nibble for the help,
and others who tried to help :)


edit: i know you probably won't c this for awhile, but i had the config to watermark both the original and resized and it started to do it on the resize just now and i didnt touch anything :D
Title: Re: Permanent Watermark with GD2
Post by: Nibbler on March 04, 2005, 04:16:40 pm
The mod doesn't watermark the thumbnail pic - that's the smallest version of the picture. When you click the thumbnail, you get the resized/normal pic, when you click the resized pic, you get the fullsize pic.
Title: Re: Permanent Watermark with GD2
Post by: squrban on March 04, 2005, 04:37:29 pm
Nibbler >> tahnk you   ;D
its just work now..I forget rename the logo.png  ;)

but I like to add the Watermark to old pic too ..so how coan I do that???

and tahnk's agen...
Title: Re: Permanent Watermark with GD2
Post by: davidshook on March 10, 2005, 04:54:27 am
hm, hate to repeat, but anyway: using watermarking isn't recommended anyway, as it will put an enormous strain on server load. Your webhost will certainly prefer it if you don't use it at all, at least if you're getting a high traffic volume (and even serve videos). Instead of using watermarking (and having the need for two separate installs), it's recommended to watermark pics permanently (before upload).

Joachim

I've seen this statement throughout the forum. I agree that this may be a big strain. However, for some this is a required functionality... and, it HAS to be done ON THE SERVER! For example, I want to allow users to upload pictures and store them on the gallery. We cannot expect teh user to watermark the pictures for us. Also, I can not go through the gallery manually every day and find out which pictures are the new ones, then download those pictures, watermark them, and upload them. This is just not practical. The watermark process on the server is about as difficult as the thumbnailing proccessing and yet we are not required to create the thumbnails on the desktop and then upload them.
I think that the fact that this subject requires a dedicated section in the forum kind of hints to the value of this feature.



PS. Has anyone figured or can expain to how to fix the problem related to the error when non-picture files are uploaded????
Title: Re: Permanent Watermark with GD2
Post by: Nibbler on March 10, 2005, 05:16:00 pm
You should be able to use the is_image() function to check if the file is an image, and only apply the watermark if it is.
Title: Fatal error
Post by: lanun on March 14, 2005, 02:51:46 am
Hi. I've applied this hack to all of the instructions but I get the following error when I do the watermark action.

Fatal error: Unsupported operand types in /home/badak/public_html/mrbadak/include/picmgmt.inc.php on line 320

the line 320
$src_x = $srcWidth - ($logoW + 5);

is this problem with my server settings? how do i check?
Title: Re: problem
Post by: melbcentral on March 17, 2005, 03:32:59 am
Hey i tried it before and it worked very good on my site. And I have changed my hosting recently and they dont support file .png and i made the change it to .jpg and .gif but i showed some error

Warning: imagecreatefrompng(/home/httpd/vhosts/vietfanclub.com/httpdocs/gallery/images/newlogo.jpg): failed to open stream: No such file or directory in /home/fanclub/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/fanclub/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/fanclub/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/fanclub/public_html/gallery/include/picmgmt.inc.php on line 323


any ideas >???

Title: Re: Permanent Watermark with GD2
Post by: foulu on March 17, 2005, 03:45:11 am
path of your server has changed, change it to right value
Title: Re: Permanent Watermark with GD2
Post by: KlausH on March 18, 2005, 12:07:06 am
I was unable to modify my original post and I do think that the top post should be the newest version. So I suggest you either split this post off or move it to the first somehow.

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


Just installed and works perfectly in CPG 132!

Thanks for this nice stuff!

Greetings

Klaus
Title: Re: Permanent Watermark with GD2
Post by: TheGamer1701 on March 22, 2005, 10:53:55 am
Hey,


I applied the hack to my page http://www.partynation.tv/ in the gallery and it works great.
BUT, unfortunetly, I can't make it work to use a transparent image...
Even if I save my png file as a transparent, it won't use it as a transparent watermark...

see the examples (I tried a few different files) in this album:
http://www.partynation.tv/coppermine/thumbnails.php?album=52
(First 4 pictures)

I use IrfanView to modify my pictures... The png file IS transparent.. I tested it with a basic html file and it works.
I attached the picture...


I really hope that someone of you can help me.
I'm not a great graphic guy... :D

(nor is my english really good, sorry)


Thx,
André
Title: Re: Permanent Watermark with GD2
Post by: TheGamer1701 on March 23, 2005, 06:50:32 pm
plz... can anyone help me?
Title: Re: Permanent Watermark with GD2
Post by: kegobeer on March 24, 2005, 12:59:17 am
If you are using Internet Explorer, you are out of luck.  IE doesn't display transparent PNG images correctly.  There's an IE PNG fix available on the web - http://koivi.com/ie-png-transparency/
Title: Re: Permanent Watermark with GD2
Post by: TheGamer1701 on March 24, 2005, 08:36:39 am
well, I'm using mozilla firefox...

and actually IE DOES display the transparent png ...
but when I try to watermark my pictures with this png, I don't get an transparent logo...
everything that's meant to be transparent appears white...


any solution?
Title: Re: Permanent Watermark with GD2
Post by: Burpee on March 24, 2005, 10:42:54 pm
Perhaps something is wrong with the way IrfanView processes transparency? I'll attach an image exported in PSP8, try it with that.
Title: Re: Permanent Watermark with GD2
Post by: kegobeer on March 24, 2005, 11:04:49 pm
Something is up, because IE does not handle PNG-24 alpha transparency correctly.  Unless of course your images are PNG-8 with binary transparency, which IE does handle properly.

Go here (http://koivi.com/ie-png-transparency/) and see how a PNG-24 image displays with and without the PHP fix.

This could be an issue with the type of PNG image you are trying to superimpose.  Try both PNG-8 and PNG-24 and see if either one of them displays correctly when applied as a watermark.
Title: Re: Permanent Watermark with GD2
Post by: Burpee on March 25, 2005, 02:05:31 am
Kegobeer, the images are applied on the server on upload. I don't think this is an issue with IE, I think it's an issue with GD2 not properly reading and applying the file.
Title: Re: Permanent Watermark with GD2
Post by: kegobeer on March 25, 2005, 02:48:54 am
Yeah, I'm sure you're correct, Burpee.  Perhaps an older version?
Title: Re: Permanent Watermark with GD2
Post by: Burpee on March 25, 2005, 03:03:26 pm
I somewhat doubt it, GD2 doesn't change that much for as far as I know. However, the file that he attached was somewhat big in size for an image that small. If you look closely, you'll see that the image I attached is only half that size. Hopefully that will fix it for him.
Title: Re: Permanent Watermark with GD2
Post by: Stramm on March 26, 2005, 05:13:38 pm
hey, that's a great mod... however there are two things I didn't like
1. no transparency for the watermark
2. it's a final step... you can't undo the watermarking

so I made a mod of the mod. You can set transparency for the watermark and you can redo watermarking. Means you can totally get rid of it, or if you just want to have another watermark.. no problem at all. Other spot on the image... not a problem at all.

So if one of you guys is interested I'd put it up here... or is it wrong to put it in that thread???
Title: Re: Permanent Watermark with GD2
Post by: Tranz on March 26, 2005, 05:38:57 pm
Please create a new thread in a board that you can post. A moderator will move accordingly.
Title: Re: Permanent Watermark with GD2
Post by: Stramm on March 26, 2005, 06:14:45 pm
OK, it's in support-1.3-misc
hope you like it
Title: Re: Permanent Watermark with GD2
Post by: TheGamer1701 on March 26, 2005, 07:49:43 pm
Hey Burpee, I just fell in Love with you :-)


That image works perfectly, thank you very much.

Do you know where the error was?
thx
Title: Re: Permanent Watermark with GD2
Post by: Burpee on April 03, 2005, 03:17:31 am
No problem :)

I think the error was that IrfanView was not producing the right kind of PNG, messing up the alpha layer.
Title: Re: Permanent Watermark with GD2
Post by: mr_summoner on April 06, 2005, 01:19:39 pm
Code: [Select]
Warning: imagecreatefrompng(): open_basedir restriction in effect. File(/PG/watermark.png) is not within the allowed path(s):
hi..
this is my  first post here. i got the above error...i think it is about "Which file to use for watermark "..
i just dont know how to insert the correct path for my watermark image.
this is my link to my watermark image... http://ftsmania.com/PG/watermark.png
my coppermine is in the PG folder.... anyone please help me...
Title: Re: Permanent Watermark with GD2
Post by: Schubi on April 21, 2005, 09:56:10 am
Is there somewhere a downloadlink for this modification?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on April 21, 2005, 10:05:01 am
no, you have to apply the changes needed for this mod manually, as suggested in the first posts in this thread.

Joachim
Title: Re: Permanent Watermark with GD2
Post by: Schubi on April 21, 2005, 01:08:14 pm
Servus GauGau! Thx - updated the files and it it works really fine! Take a look here (http://microslave.de)!
Title: Re: Permanent Watermark with GD2
Post by: yaakoob on April 25, 2005, 01:06:28 am
You should be able to use the is_image() function to check if the file is an image, and only apply the watermark if it is.

Can you give a little more info about how to use that function in coppermine to prevent error with non-picture files? My php skills are basic at best and my coppermine skills are even worse.

Title: Re: Permanent Watermark with GD2
Post by: ggnetworks on May 08, 2005, 07:15:42 pm
does all images that are batched get the watermark? also the original size image, like when u click on an image and it opens up in 100% scale, will that be watermarked too?
Title: Re: Permanent Watermark with GD2
Post by: fedexx on May 14, 2005, 04:22:45 am
Hello! I was seeing the code, proving it I have realized that when upload swf files gives error and upload cannot be done, somebody has solved east error?
Title: Re: Permanent Watermark with GD2
Post by: pgrzegorc on June 12, 2005, 05:39:37 pm
And how to add diffenren watermarks ( not only 1 watermark whole all albums, categories ) for diferent users during upload???
Because in my gallery about 20 users can upload files and I want that each user will be have own watermark - it's obvious, but how to it do during uploading? any hacks???


Pawel
Title: Re: Permanent Watermark with GD2
Post by: djmac on June 22, 2005, 10:14:22 pm
Burpee

I was able to install your mod without any errors. I also don't get any results.  :-[  I also notice that the watermark image block in the config isn't saving the data enterd. Although the (path) and (1) and (both) are in the SQL. GD2 is available by default both in php and perl.
 
In your post you say (the prefix highlighted in red should be edited by the user to make sure it corresponds to their gallery prefix.. latest CPG should have cpg130 as prefix.) I am running 1.3.2 of CPG, so I used the prefix of 132 which the other tables were using. Was that the correct thing to do. Other than that I am all eyes on your advice.

Regards
Don
Title: Re: Permanent Watermark with GD2
Post by: -TRshady- on June 29, 2005, 05:49:00 pm
Hey Burpee, thanks for a great mod, am having a problem though:


1. When batch adding , the original full size image does not get watermarked
Check this Image as an example. (http://trshady.com/cpg133/displayimage.php?album=random&cat=2&pos=-11) << Was batched added but when you click to view the larger image, no watermark is seen.
Then check this image. (http://trshady.com/cpg133/displayimage.php?album=1&pos=0) << was uploaded through the 'upload a file' button and you can see the full size image did get watermarked.

So what could be preventing the full size image getting watermarked when batch adding?

2. Broken 'result image' when batch adding

My second problem is when batch adding for watermarking. The results screen which usually shows 'OK', 'DP' and so on for example is a broken image. What would be causing this and could you offer a solution?

Would greatly appreciate the help!
Title: Re: Permanent Watermark with GD2
Post by: -TRshady- on June 30, 2005, 12:27:18 pm
Anyone able to help with this?  :\'(
Title: Re: Permanent Watermark with GD2
Post by: -TRshady- on July 05, 2005, 02:27:26 am
5 days later ... where are you burpee?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on July 05, 2005, 08:01:16 am
mod authors rarely re-visit their thread. As sf.net has disabled outbound email traffic, there's no currently not even notification working. I guess you're on your own with this.
Title: Re: Permanent Watermark with GD2
Post by: yaakoob on July 18, 2005, 06:13:56 am
You should be able to use the is_image() function to check if the file is an image, and only apply the watermark if it is.

Can you give a little more info about how to use that function in coppermine to prevent error with non-picture files? My php skills are basic at best and my coppermine skills are even worse.


Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on July 18, 2005, 07:48:46 am
read my posting just one above yours. This mod goes unsupported by the original author, you're on your own when using it. If people don't answer your question, it usually means that they don't know the answer or that they don't want to answer. Read FAQ: I've posted my question a while ago, but nobody answers. What the...? (http://coppermine.sourceforge.net/faq.php#lamesupport)
Title: Re: Permanent Watermark with GD2
Post by: _Samantha_ on August 01, 2005, 05:26:58 am
Hi @ll!

Of you chop functioned great, however only in English! Does it
give not also into German?

please help me ...

 ::)

_Samantha_
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on August 02, 2005, 09:39:18 am
please rephrase your question, I don't understand (and I don't think others will). You might want to illustrate your question with a screenshot.
Title: Re: Permanent Watermark with GD2
Post by: _Samantha_ on August 02, 2005, 01:51:54 pm
Apology asks, if I expressed myself so misleadingly, but mine english
is not very good. Thanks, which answered me someone. My problem: that
chop can only in "english.php" be used, one presupposes thus, the
baking and front-end are "English". I however would like a German
copilot by mine baking and front-end. The Howto refers however only to
"english.ph" - I need the Howto for "german.php". Or do I make which
traffic and I can chop just as well to "german.php" to apply?

Who can help me?

-- Samantha --
Title: Re: Permanent Watermark with GD2
Post by: Nibbler on August 02, 2005, 03:04:20 pm
You can safely apply the changes to the german.php instead of english.php.
Title: Re: Permanent Watermark with GD2
Post by: undeshila on August 04, 2005, 07:36:45 pm
GREAT mod , tnx
i've added the mod , no problem , all the new pics get watermarked , BUT , i also want to watermark the old images. As mentioned on the 2nd page i think , i went to the util.php , found the utility to watermark albums , only that , i have 600+ albums .... and modifing each and everyone will be hell.

Can someone tell me a way to select ALL the albums pls ?!
Title: Re: Permanent Watermark with GD2
Post by: Stramm on August 04, 2005, 08:08:34 pm
you'll have to modify the code for that
open util.php and find function updatethumbs()
a few lines below you'll see
Code: [Select]
    $query = "SELECT * FROM $picturetbl WHERE aid = '$albumid'";
replace it with
Code: [Select]
    $query = "SELECT * FROM $picturetbl";

now it doesn't matter what album you set in the admin tools... coppermine will just process them all
Title: Re: Permanent Watermark with GD2
Post by: undeshila on August 05, 2005, 12:58:25 pm
you'll have to modify the code for that
open util.php and find function updatethumbs()
a few lines below you'll see
Code: [Select]
    $query = "SELECT * FROM $picturetbl WHERE aid = '$albumid'";
replace it with
Code: [Select]
    $query = "SELECT * FROM $picturetbl";

now it doesn't matter what album you set in the admin tools... coppermine will just process them all




i did the modification , but unfortunatelly its only watermarking the album chosen , not all of them
Title: Re: Permanent Watermark with GD2
Post by: Stramm on August 05, 2005, 01:12:41 pm
Then you've changed the wrong line... read again, find the function updatethumbs() and a few lines below find the line you'll have to edit
Title: Re: Permanent Watermark with GD2
Post by: undeshila on August 05, 2005, 01:33:57 pm
no , there's only one part of the code with both specifications

take a look @ the photo (https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.undecided.ro%2Fcode.jpg&hash=83937673343786b6655e8e77b2a2a09b6fda7fd5)
Title: Re: Permanent Watermark with GD2
Post by: Stramm on August 05, 2005, 01:55:28 pm
OK, reverse engineering.. the author has introduced a new function vesileimaathumbit() that's modifying the watermarked pics. I just used the existing one.. therefore the confusion

find it and a few lines below you'll see
Code: [Select]
   $query = "SELECT * FROM $picturetbl WHERE aid = '$albumid'";replace with
Code: [Select]
   $query = "SELECT * FROM $picturetbl";
Title: Re: Permanent Watermark with GD2
Post by: sigepjedi on August 24, 2005, 04:50:41 pm
Any update for 1.4?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on August 26, 2005, 05:41:53 pm
cpg1.4 goes unsupported, please stop posting issues related to it.
Title: Re: Permanent Watermark with GD2
Post by: pisaleve on August 27, 2005, 11:40:44 pm
it is possible to place watermark in the original image and resize?
 I modified form in the page: config.php

       <td class="tableb" valign="top">
                               <input type="Checkbox" name="$name" class="listbox" value="both" $both_selected>{$lang_config_php['wm_both']}</option>
                               <input type="Checkbox" name="$name" class="listbox" value="original" $original_selected>{$lang_config_php['wm_original']}</option>
                               <input type="Checkbox" name="$name" class="listbox" value="resized" $resized_selected>{$lang_config_php['wm_resized']}</option>
               </td>

But exactly selecting both, he does not function ...
An image only is with watermark
Title: Re: Permanent Watermark with GD2
Post by: Soulmaster on September 22, 2005, 10:00:22 am
getting this error

Warning: imagecreatefrompng(/c://apachefriends/xampp/htdocs/gallery/images/watermark.png) [function.imagecreatefrompng]: failed to open stream: Invalid argument in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 302

Warning: imagesx(): supplied argument is not a valid Image resource in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 303

Warning: imagesy(): supplied argument is not a valid Image resource in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 304

Warning: imagecopy(): supplied argument is not a valid Image resource in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 321

Warning: imagecreatefrompng(/c://apachefriends/xampp/htdocs/gallery/images/watermark.png) [function.imagecreatefrompng]: failed to open stream: Invalid argument in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 302

Warning: imagesx(): supplied argument is not a valid Image resource in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 303

Warning: imagesy(): supplied argument is not a valid Image resource in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 304

Warning: imagecopy(): supplied argument is not a valid Image resource in C:\apachefriends\xampp\htdocs\gallery\include\picmgmt.inc.php on line 321

dunno what it means
Title: Re: Permanent Watermark with GD2
Post by: sigepjedi on September 25, 2005, 03:43:37 am
cpg1.4 goes unsupported, please stop posting issues related to it.

i didnt realize asking about a MOD or HACK fell into ANYTHING to do with the fact that 1.4 is unsupported.
Are you implementing that a "HACK" is supported????

- Now back to your regularly sched program.
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on September 25, 2005, 08:47:05 am
This is a mod that was made for cpg1.3.x. You repeatedly asked for this mod to be ported for cpg1.4.x. That's very selfish behaviour in the first place, you could have ported it yourself and shared your findings. However, you chose to bump, that's why I told you to stop. In fact, we don't want you to use cpg1.4.x yet if you have no idea how to port the mods and hacks you need over from cpg1.3.x to cpg1.4.x, as this means that you're not experienced enough to use cpg1.4.x yet. Of course we can't stop you from using cpg1.4.x, but we can try to stop you from cluttering threads that deal with cpg1.3.x stuff with your questions that are related to an unsupported version. Imo we have a different concept of what "unsupported actually means, however I suggest you respect our concept of the word.

@all: please do not reply to this thread to ask for a port to another version, will you?
Title: Re: Permanent Watermark with GD2
Post by: RJPotts on October 04, 2005, 02:15:53 am
Hello!
I used this mod and added an ability to choose between image watermark and a simple text watermark.
<snip>

Hi,

I had this text watermark mod added to my gallery, working successfully both for uploaded files and admin use on previously uploaded files.

I was recently notified of an error during uploading, ".....failed to open stream: Permission denied.....", I did some digging around on here and discovered that it was a result of the CHMOD settings on the albums directory which I then changed to 755.  I can only presume that my hosts recent 'upgrade' of their servers accounted for the permissions having been changed as several hundred pictures had been uploaded and no coppermine / mod files altered.

After setting the permissions back to what they should be I tried uploading a sample file, it uploaded ok but when I selected the folder etc for in to be placed in I got the error message "Fatal error: Call to undefined function: imagettftext() in /home/cameyinf/public_html/gallery/include/picmgmt.inc.php on line 356".  As that line was related to the mod I removed the modded files and replaced them with the original coppermine versions and I was able to upload successfully. 

I then added the image watermark mod & it worked as advertised, when I (very carefully!) added the text watermark mod the problem (Fatal error: Call to undefined function: imagettftext() in /home/cameyinf/public_html/gallery/include/picmgmt.inc.php on line 356) returns.

Has anyone come across this problem before & is able to tell me whats gone wrong?  I did try searching the library but couldnt find anything relevant, if it has been discussed before I apologise & hope someone might point me in the right direction.

TIA
Richard

PS, I never had config menu entries for the text watermark mod (during original install or the new install today) but it didnt really matter as set it up manually in phpmyadmin, did anyone else find this?
Title: Re: Permanent Watermark with GD2
Post by: Stramm on October 04, 2005, 09:16:46 am
you need to recompile php with support for imagettftext enable-gd-native-ttf
Title: Re: Permanent Watermark with GD2
Post by: RJPotts on October 04, 2005, 10:51:38 am
you need to recompile php with support for imagettftext enable-gd-native-ttf

Many thanks indeed.

I've just been on a googling trip to try & find out how to do the above.  However, as I havnt got a clue what I'm doing with PHP etc I have no idea if the stuff I'm finding is relevant / what I need to do.

As the problem has only surfaced after server changes I've just contacted the host with the above info & will see what they say.  In anticipation of their reply not being particularly useful might I trouble you to point me in the direction of instructions on how a PHP (complete!) newbie can recompile?

Rgds & many thanks
Richard
Title: Re: Permanent Watermark with GD2
Post by: Tranz on October 04, 2005, 05:16:54 pm
Sorry, only your host can recompile PHP.
Title: Re: Permanent Watermark with GD2
Post by: RJPotts on October 05, 2005, 07:41:01 am
Sorry, only your host can recompile PHP.

Ah, ok, it's probably quite good that I cant meddle with it :)

They were actually quite useful and have recompiled PHP with 'freetype' support, while the original error msg has cleared I now get another one when I try to add watermarks "Warning: imagettftext(): Could not find/open font in /home/cameyinf/public_html/gallery/include/picmgmt.inc.php on line 356".  That line points to 'home/cameyinf/public_html/arial.ttf' (as it always did) and the font is still where it previously was.

I've just emailed the hosting company again but in the meantime, do any of the experts here know of a fix I can make?

Rgds & many thanks
Richard
Title: Re: Permanent Watermark with GD2
Post by: Stramm on October 05, 2005, 11:42:33 am
check if that's really the absolute path. After a reconfig things may have changed. When it was before /home... it may be now /usr/home...
Open a ssh session cd to your fontfile and type pwd. This will spitz out the path... now that you're already there, check permissions (and owners) and change permissions if necessary
Title: Re: Permanent Watermark with GD2
Post by: vincenzo_hk on October 05, 2005, 08:42:48 pm
Every day I need to update 1000 pics in some of the albums, Is it possible only watermark the New Pics? not run the Whole albums files once again!

Thanks
Title: Re: Permanent Watermark with GD2
Post by: TheGamer1701 on October 14, 2005, 02:39:37 pm
Hello,

this is really a great mod, but I'm missing a little feature here:

I don't want to watermark private albums.
So, how can I modify this hack?

Any idea?
I tried it with the picmgmt.php file with the first entry, but that did not work.
If you could give me a hint to the right location in the code, I guess I can do this on my own then..

Thx,
André
Title: Re: Permanent Watermark with GD2
Post by: nytemare on October 27, 2005, 10:55:16 am
I am having a problem with the MOD, i installed it and it sorta worked fine, had no problems and got it to watermark pictures. However, i noticed that it didn't watermark everything, a few files were missed out. Here's a link to an album which i tried to watermark http://www.azngirls.net/gallery/thumbnails.php?album=7 You will find that the original pictures, which are the bigger ones would have been watermarked where as the smaller sized pictures (not the small thumbnails) which you click on to see the larger image does not get watermarked.

Has anyone else come across similar problems?
Title: Re: Permanent Watermark with GD2
Post by: nytemare on October 27, 2005, 11:14:56 am
Another thing just happened.. check out the first 2 thumbnails or rather in all of the thumbnails you can see my watermark, but in a previous album i watermarked, the thumbnails didn't get affected. And what's weird is that some of the thumbnails have the watermark when you click and see the normal resized image it doesn't show a watermark.. and when you view the original picture than you can see a watermark again. It's all so confusing.
Title: Re: Permanent Watermark with GD2
Post by: RIDDICK on January 02, 2008, 01:27:53 am
First of all excuse me my English...I'm from Ukraine ::)

Please! Help me with putting the watermark!!! :'(
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on January 02, 2008, 08:22:43 am
Just read the thread you're replying to and do as suggested here. Just a generic "help me" doesn't really mean anything. Post details (what you did, what exactly doesn't work as expected) if you really ned help. Posting a link to your gallery is almost mandatory. If needed, post a non-admin test user account as well.
Title: Re: Permanent Watermark with GD2
Post by: RIDDICK on January 02, 2008, 06:49:51 pm
Thanks a lot!
So...
Here is the gallery : http://arttalk.ru/gallery
Here is the test accaunt:
Test_user
pass: test

When I try to install the mod from this topic, I have a problem with the config.php file.

Quote
4.
Open file config.php

Find this:
Code:
function create_form(&$data)

there is no such line in it ???  May be i don't understend something...my English is very poor, so I need your help.
Thank you!

Title: Re: Permanent Watermark with GD2
Post by: Stramm on January 02, 2008, 06:59:41 pm
this mod is for the outdated version 1.3.x, you're running 1.4.14
Title: Re: Permanent Watermark with GD2
Post by: RIDDICK on January 02, 2008, 07:39:42 pm
 :o Ok, what I need to do&
Title: Re: Permanent Watermark with GD2
Post by: Stramm on January 02, 2008, 07:47:30 pm
look for a watermarking mod/ plugin that's coded for CPG 1.4.x
Title: Re: Permanent Watermark with GD2
Post by: RIDDICK on January 02, 2008, 08:22:08 pm
http://forum.coppermine-gallery.net/index.php?topic=29817.0

This one?
Title: Re: Permanent Watermark with GD2
Post by: Joachim Müller on January 03, 2008, 09:03:36 am
Any mod that has been designed for your version. All of those mods have advantages and disadvantages. Read the announcement threads and then decide for one. Locking this thread.