Advanced search  

News:

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

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

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

0 Members and 1 Guest are viewing this topic.

Burpee

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 71
    • Vuurwerklook.com
Permanent Watermark with GD2
« Reply #20 on: March 29, 2004, 01:21:05 am »

 
*ahem*


okay, it's 1:30 am and I've got 5 and a half hours of sleep ahead of me so I wanna make this quick...
I've installed the mod on my gallery... I'm not very good at PHP, but I'm learning steadily.

When I try uploading a foto normally (with watermark on upload) it gives me the following error:

Quote
De foto 'albums/userpics/10001/592314802.jpg' kan niet ingevoegd worden in het album.


Warning: getimagesize(albums/userpics/10001/normal_592314802.jpg): failed to open stream: No such file or directory in /home/vuurwerk/public_html/galleryhidden/include/picmgmt.inc.php on line 224

now... it could just be something stupid I did... I dunno..

thanx in advance :D


Burpee
« Last Edit: April 30, 2004, 12:04:47 am by Burpee »
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Permanent Watermark with GD2
« Reply #21 on: March 29, 2004, 07:15:12 am »

Thanks - the whole thing of
1)watermark image on upload,
2)where to place the watermark,
3)which file to use for watermark
4)which files to watermark

Needs to be admin settable - are you feeling upto doing that as well?

Once you are thru I intend to write a watermark function for Image MagicK and we would  have completed the Watermark feature :)
Logged
SANIsoft PHP applications for E Biz

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Watermarking settings
« Reply #22 on: March 29, 2004, 11:41:16 am »

Quote from: "tarique"
Thanks - the whole thing of
1)watermark image on upload,
2)where to place the watermark,
3)which file to use for watermark
4)which files to watermark

Needs to be admin settable - are you feeling upto doing that as well?

Once you are thru I intend to write a watermark function for Image MagicK and we would  have completed the Watermark feature :)


I dont know if I have knowledge to do it, but I will try.
Correct if I go wrong in first step: config values should be saved into table named "someprefix_config"?
And I think those settings should be settable from config.php?
Logged

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #23 on: March 29, 2004, 11:43:40 am »

Quote from: "Burpee"

When I try uploading a foto normally (with watermark on upload) it gives me the following error:

Quote
De foto 'albums/userpics/10001/592314802.jpg' kan niet ingevoegd worden in het album.


Warning: getimagesize(albums/userpics/10001/normal_592314802.jpg): failed to open stream: No such file or directory in /home/vuurwerk/public_html/galleryhidden/include/picmgmt.inc.php on line 224


now... it could just be something stupid I did... I dunno..

Hi Burbee

I'll try to check it.
What does "De foto 'albums/userpics/10001/592314802.jpg' kan niet ingevoegd worden in het album" mean in english?
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Re: Watermarking settings
« Reply #24 on: March 29, 2004, 12:41:02 pm »

Quote from: "Sammy"
I dont know if I have knowledge to do it, but I will try.
Correct if I go wrong in first step: config values should be saved into table named "someprefix_config"?
And I think those settings should be settable from config.php?


As long as you are willing to learn we will be willing to help :) Here are some tips to get you started

To add an option to the Config screen you need to
1) edit the language file for example open english.php and search for "config.php" below that you will find all the arrays which are needed to create the config screen. Since you will be mostly adding "yes"  "no" options what you need to add is something like this
Code: [Select]
array('Watermark Image on upload', 'enable_watermark', 1),

2) You need to add a record to the cpg_config table with name = "enable_watermark"

3) Then in your scripts the state of "enable_watermark" will be available in
Code: [Select]
$CONFIG['enable_watermark']

Try it out and let me know if you need further help :)
Logged
SANIsoft PHP applications for E Biz

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Something done with watermarking...
« Reply #25 on: March 29, 2004, 09:57:58 pm »

@Tarique

Thanks for tips!
I have now done it to admin settings.
Now I try to get those watermark scripts to understand those admin settings.

By the way, if You have looked modified picmgmt.inc.php, tell Me if next part is needed at all?
Code: [Select]
           $imginfo = getimagesize($src_file);
            if ($imginfo == null) {
                $ERROR = $lang_errors['resize_failed'];
                @unlink($src_file);
                return false;
            } else {
                return true;
            }


I wonder it becouse just checked about @unlink() function, and noticed that it's for deleting a file.
Logged

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #26 on: March 29, 2004, 10:15:04 pm »

@ Burpee

Is there possibility, that image that gave error, is so small that there are no original and normal (resized) image?
I've got same error, when trying to upload small pic.

We need to make check in watermarking, so there wont come that error, if pic is smaller than size of intermediate picture.
Logged

Burpee

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 71
    • Vuurwerklook.com
Permanent Watermark with GD2
« Reply #27 on: March 29, 2004, 10:19:28 pm »

Quote from: "Sammy"
Quote from: "Burpee"

When I try uploading a foto normally (with watermark on upload) it gives me the following error:

Quote
De foto 'albums/userpics/10001/592314802.jpg' kan niet ingevoegd worden in het album.


Warning: getimagesize(albums/userpics/10001/normal_592314802.jpg): failed to open stream: No such file or directory in /home/vuurwerk/public_html/galleryhidden/include/picmgmt.inc.php on line 224


now... it could just be something stupid I did... I dunno..

Hi Burbee

I'll try to check it.
What does "De foto 'albums/userpics/10001/592314802.jpg' kan niet ingevoegd worden in het album" mean in english?


I think it was just an error I made somehow. It's working fine now anyway. Maybe I was doing something stupid but I wasn't entirely awake when I wrote the previous post, sorry about that.

I'm loving the mod tho...
one aspect I am worried about, is it still possible to upload movies? I know there's already a discussion about this in "Coppermine should also allow video" but I think that the creator of the watermark mod has a better perspective on possible solutions :D

Seeing as I'm not very experienced in php I might be sounding stupid as hell, but isn't it just as simple as just telling the watermark code to ignore all formats other than jpg and png?

When I upload a movie it just tells me (roughly translated):
Quote
The photo 'albums/userpics/10001/cube1.mpg' cannot be inserted to the album.

If you are using the GD image library only the formats JPG and PNG are allowed.

But to be quite honest I just realized this is the first time I've tested the movie upload function.... hmm... if only I had more time so I could test everything every time I wanted to... but hey time is scarce

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #28 on: March 29, 2004, 10:50:40 pm »

@Burpee
I cant help You with that movie uploading right now.
I think it can be quite easy to by pass watermarking of anything else, than JPG or PNG, but not sure about it.
Maybe Tarique or some other Guru can tell, if putting "break" or some  other "get a way from this watermarking function"-command on watermark scripts imagetype checking part would do that?
Code: [Select]

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


I'm working now with those admin settings on watermarking.
There will be (actually I have done that part allready) easy way to turn watermarking off from the setings. So at least You can drop watermarking off when uploading movies and turn it back when you want it.
Logged

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
GD2 Watermark
« Reply #29 on: March 30, 2004, 12:00:46 am »

Quote from: "tarique"
Thanks - the whole thing of
1)watermark image on upload,
2)where to place the watermark,
3)which file to use for watermark
4)which files to watermark

Needs to be admin settable - are you feeling upto doing that as well?

Once you are thru I intend to write a watermark function for Image MagicK and we would  have completed the Watermark feature :)


@Tarique
It's done with Your great tips, that lead me to succes :D
Dont know about how clean code it is, but it's working.

I updated the zip file and added 4 SQL insert lines in txt file.

There needs to be done check for image size.
If (image size <= intermediate image size on settings) {
  no need to watermark intermediateprefix_imagename;
  Break (or some command to stop watermarking of this pic);
}
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Re: GD2 Watermark
« Reply #30 on: March 30, 2004, 05:20:38 am »

Quote from: "Sammy"
@Tarique It's done with Your great tips, that lead me to succes :D
Dont know about how clean code it is, but it's working.

Great work!! 8)
I will look into the code in a day or two I am busy with some interviews right now

Thanks
Logged
SANIsoft PHP applications for E Biz

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #31 on: March 30, 2004, 10:58:37 pm »

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

This MOD uses GD2!

Here is how to mod (original) CPG 1.2.1 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


You can download modified files in a zip file from here, or You can do modifications by Your self.


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('Enable debug mode', 'debug_mode', 1),

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', 8),
                array('which files to watermark', 'which_files_to_watermark', 9),
                array('Which file to use for watermark', 'watermark_file', 0),


Find this:
Code: [Select]
'select_album' => 'Select album',

Add this after it
Code: [Select]

        'watermarks' => 'Add watermaks',
        'watermark_normal' => 'Resized images only',
        'watermark_image' => 'Original sized only',
        'watermark_both' => 'Original and resized images',
        'watermark_wait' => 'Watermarking images...',
        'watermark_continue_wait' => 'Continuing to watermarking originals and/or resized images...',



2.
Open file include/picmgmt.inc.php

Find this:
Code: [Select]
$image_filesize = filesize($image);

Add this before it
Code: [Select]

                //Adds watermarks to new images
                if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original') {
                        if (!watermark($image))  //this is for full size image
                                return false;
                }
                if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') {
        if (!watermark($normal))  //this is for intermediate size image
            return false;
                }
               


Find this:
Code: [Select]
?>

Add this before it
Code: [Select]

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

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

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

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




3.
Open File util.php

Find this:
Code: [Select]
function deleteorig()

Add this before it
Code: [Select]

function vesileimaathumbit()   //watermarkthumbs
{
    global $picturetbl, $CONFIG, $lang_util_php;
    $phpself = $_SERVER['PHP_SELF'];
    $albumid = $_POST['albumid'];
    $updatetype = $_POST['updatetype'];
    $numpics = $_POST['numpics'];
    $startpic = 0;
    $startpic = $_POST['startpic'];

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

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

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

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

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

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

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

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

    if ($startpic < $totalpics) {

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



Find this:
Code: [Select]
filenametotitle(0);

Add this before 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]
// Add triple dropdwon later - put back in for compatibility reasons

Few lines below is
Code: [Select]
die('Invalid action');

Now we need to paste this
Code: [Select]

                //Watermark place
                case 8 :
                    form_watermark($element[0], $element[1]);
                                        break;
                                //Which filest to watermark
                case 9 :
                    form_watermark2($element[0], $element[1]);
                                        break;
                case 10 :
                    // 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]

                // Thumbnail scaling
                case 7 :
                    form_scale($element[0], $element[1]);
                    break;  // Add triple dropdwon later - put back in for compatibility reasons
                //Watermark place
                case 8 :
                    form_watermark($element[0], $element[1]);
                                        break;
                                //Which filest to watermark
                case 9 :
                    form_watermark2($element[0], $element[1]);
                                        break;
                case 10 :
                    // do nothing
                    break;
                default:
                    die('Invalid action');
            } // switch
        } else {
            form_label($element);



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

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



Thats it. Now You can go to setting and set it up.
Actually You need to go there, before trying to add new pics.
You have to chage 'Which file to use for watermark' to point in Your ow transparen logo.png file that is used as watermark.

There is no check for Your intermediate sized pictures, so if Your pics are smaller that intermediate pic size, You'll get errors for no image found.[b/]
There are some solution to come for that problem.


This should contain every modification I have made.
Logged

raindeer

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Permanent Watermark with GD2
« Reply #32 on: March 31, 2004, 07:04:20 am »

hello sammy,

 I tried your changes on a new just installed photo album, then when trying to upload the photo;s I got this two messages...

Warning: getimagesize(): Unable to access albums/userpics/normal_strand-0030.jpg in /home/httpd/vhosts/partypicas.nl/httpdocs/copper/include/picmgmt.inc.php on line 231

Warning: getimagesize(albums/userpics/normal_strand-0030.jpg): failed to open stream: No such file or directory in /home/httpd/vhosts/partypicas.nl/httpdocs/copper/include/picmgmt.inc.php on line 231

 It's some hours and reinstallations later.... and still the same problem...

Have you got any idea's ???

Reinier
Logged

raindeer

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Permanent Watermark with GD2
« Reply #33 on: March 31, 2004, 07:29:03 am »

sorry,

 I have read it here before, the resizing was the problem,
my imported images were smaller than the risize sizes....

 so the problem is solved...

 or maybe it is possible to make somewhere an if parameter, when the original is smaller than the risize size....  

 ps I'm an absolute no-no in php....

Reinier
Logged

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #34 on: March 31, 2004, 07:35:51 am »

Quote from: "raindeer"
sorry,

 I have read it here before, the resizing was the problem,
my imported images were smaller than the risize sizes....


 or maybe it is possible to make somewhere an if parameter, when the original is smaller than the risize size....  

Reinier


@raindeer

I am working with that image size problem, but i'm not a guru PHP, so it takes time :(
I hope I get it tonight
Logged

Nawaf

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Permanent Watermark with GD2
« Reply #35 on: March 31, 2004, 07:48:28 am »

Hi,

i tried it but i got this error when i tried to Make the settings from control panel

Watermarking images...

Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 275

Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 276

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 293
albums/userpics/infarct.jpg updated succesfully!

Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 275

Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 276

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 293
albums/userpics/infarct.jpg updated succesfully!

Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 275

Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 276

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 293
albums/userpics/art_normal.jpg updated succesfully!

Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 275

Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 276

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/content/d/o/c/docarabiacom/html/cpg/include/picmgmt.inc.php on line 293
albums/userpics/art_normal.jpg updated succesfully!
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Permanent Watermark with GD2
« Reply #36 on: March 31, 2004, 07:48:44 am »

I am sorry I don't get what the problem is if it is just a question of normal_ not being present put a @in front and the warning will not be displayed - if this hack is not acceptable then do a
Code: [Select]
print_r($CONFIG)

Look up which value you want to test for and put an if condition
Logged
SANIsoft PHP applications for E Biz

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #37 on: March 31, 2004, 10:47:46 am »

@Tarique

I have tried to add an if condition for watermarkin normal sized pics

I was thinking something like
Code: [Select]


                if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal) {
                        if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') {
                                if (!watermark($normal))  //this is for intermediate size image
                                return false;
                        }
                }

in add_picture function where it triggers watermarking for new pics.

What does the ! mark do before !file_exists function in first if condition above? :oops:
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Permanent Watermark with GD2
« Reply #38 on: March 31, 2004, 11:22:55 am »

the ! before any condition negates it. In other words ! is short hand for "NOT"
Logged
SANIsoft PHP applications for E Biz

Sammy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 27
Permanent Watermark with GD2
« Reply #39 on: March 31, 2004, 11:27:20 am »

Quote from: "Nawaf"
Hi,

i tried it but i got this error when i tried to Make the settings from control panel

Watermarking images...


I dont understand, how You get it from settings panel.
Check that You have modify right files.
Logged
Pages: 1 [2] 3 4 5 6   Go Up
 

Page created in 0.042 seconds with 19 queries.