Permanant watermark with undo possibility (GD2+IMagick) for 1.4.3 Permanant watermark with undo possibility (GD2+IMagick) for 1.4.3
 

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

Main Menu

Permanant watermark with undo possibility (GD2+IMagick) for 1.4.3

Started by TheGamer1701, January 06, 2006, 03:35:02 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

TheGamer1701

Hello,

this is my first try for a modification, so bare with me if there are mistakes.
And I also hope that this is the right place to put it into.
This modification is based on the Mod by Stramm: http://forum.coppermine-gallery.net/index.php?topic=16286.0

It's still under develpoment and this thread is supposed to be a help to complete it.
I did not create a new mod, it's just a conversion of the old 132 mod for the new coppermine version (1.4.3)



The mod doesn't produce any kind of error, uploading works just fine, but the images doen't get watermarked. I did not have enough time to look into the code today, I'll hopefully have enough time by tomorrow.
I'll post the mod instructions with the next post

what's working:
- uploading of files works
- all 3 files are created (full sized file, resized file, thumbnail)

what's not working:
- watermarking at all (:-( )

TheGamer1701

Okay,
so let's begin.
First we need some sql statements.
I would suggest to execute them one by one, this way it's easiert to track down errors.
I had the problem that some etrys already existet because I installed CPGMark and when deinstalling CPGMark it seemed that it did not delete those entries.


insert into cpg_config (name, value) values ('enable_watermark', '1');
insert into cpg_config (name, value) values ('where_put_watermark', 'bottomright');
insert into cpg_config (name, value) values ('watermark_file', '/your/full/path/to/logo.png');
insert into cpg_config (name, value) values ('which_files_to_watermark', 'both');
insert into cpg_config (name, value) values ('orig_pfx', 'orig_');
insert into cpg_config (name, value) values ('watermark_transparency', '0');
insert into cpg_config (name, value) values ('watermark_transparency_featherx', '0');
insert into cpg_config (name, value) values ('watermark_transparency_feathery', '0');




Okay,
now let's begin.
What files need to be edited?
language/german.php (or your language file, e.g. english.php)
admin.php
util.php
delete.php
editpics.php
searchnew.php
include/picmgmt.inc.php (we make a complete new file)



so, let's start with your language file.
open german.php
in $lang_admin_data
find
// ------------------------------------------------------------------------- //
// File db_ecard.php
// ------------------------------------------------------------------------- //

and a few lines before find
);
before add
  // Watermarking mod
  'Wasserzeichen',
  array('Wasserzeichen aktivieren', 'enable_watermark', 1),
  array('Wo soll das Wasserzeichen eingefügt werden', 'where_put_watermark', 11),
  array('Welche Dateien sollen mit einem Wasserzeichen versehen werden', 'which_files_to_watermark', 12),
  array('Welche Datei soll für das Wasserzeichen verwendet werden', 'watermark_file', 0),
  array('Transparenz 0-100 für gesamtes Bild', 'watermark_transparency', 0),
  array('Koordinate der transparenten Farbe X (Nur GD2)', 'watermark_transparency_featherx', 0),
  array('Koordinate der transparenten Farbe y (Nur GD2)', 'watermark_transparency_feathery', 0),
  // End Mod



in $lang_util_php
find
'delete_orphans' =>
after add
  // Watermarking mod
  'update_full' => 'Beide Bilder (falls eine Kopie des Originals vorhanden ist)',
  'delete_back' => 'Backup des Originals löschen (Wenn du dies tust kannst du das Wasserzeichen nicht mehr entfernen/ändern)',
  'delete_back_explanation' => 'Diese Option löscht alle Original Bilder. Wenn du diese Option ausführst kannst du hinterher die Wasserzeichen bei bestehenden Dateien weder ändern noch entfernen.',
  // End mod


in $lang_delete_php
find
// ------------------------------------------------------------------------- //
// File displayecard.php
//



few lines before find
);

before add
  // Watermarking mod
  'orig_pic' => 'Original Bild',


go to end of file
find
?>
before add
// Watermarking mod
$lang_config_php = array(
  'wm_bottomright' => 'Unten Rechts',
  'wm_bottomleft' => 'Unten Links',
  'wm_topleft' => 'Oben Links',
  'wm_topright' => 'Oben Rechts',
  'wm_center' => 'Mitte',
  'wm_both' => 'Beide',
  'wm_original' => 'Original',
  'wm_resized' => 'Zwischengröße');



open admin.php
find
function create_form(&$data)
before add
// Watermarking mod start
function form_watermark($text, $name)
{
    global $CONFIG, $lang_config_php;

    $value = $CONFIG[$name];
    $southeast_selected = ($value == 'southeast') ? 'selected' : '';
    $southwest_selected = ($value == 'southwest') ? 'selected' : '';
    $northwest_selected = ($value == 'northwest') ? 'selected' : '';
    $northeast_selected = ($value == 'northeast') ? 'selected' : '';
    $center_selected = ($value == 'center') ? 'selected' : '';

    echo <<<EOT
        <tr>
            <td class="tableb">
                        $text
        </td>
        <td class="tableb" valign="top">
                        <select name="$name" class="listbox">
                                <option value="southeast" $southeast_selected>{$lang_config_php['wm_bottomright']}</option>
                                <option value="southwest" $southwest_selected>{$lang_config_php['wm_bottomleft']}</option>
                                <option value="northwest" $northwest_selected>{$lang_config_php['wm_topleft']}</option>
                                <option value="northeast" $northeast_selected>{$lang_config_php['wm_topright']}</option>
                                <option value="center" $center_selected>{$lang_config_php['wm_center']}</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;
}
// Watermarking mod end



find
form_number_dropdown($element[0], $element[1]
few lines below find
default:
die('Invalid action');

before add
// Watermarking Mod
//Watermark place
   case 18 :
       form_watermark($element[0], $element[1]);
       break;
//Which filest to watermark
    case 19 :
        form_watermark2($element[0], $element[1]);
        break;
    case 20 :
// do nothing
        break;
// End Mod

TheGamer1701

open util.php
find
<input type="radio" name="updatetype" id="updatetype3" value="2" checked="checked" class="nobg" /><label for="updatetype3" class="clickable_option">'.$lang_util_php['update_both'].'</label><br />'.$lang_util_php['update_number'].'
after add
<input type="radio" name="updatetype" value="3" id="full" class="nobg" /><label for="full" accesskey="a" class="labelradio">' . $lang_util_php['update_full'] . '</label><br />


find
'del_norm' => array('del_norm', $lang_util_php['delete_intermediate'], $lang_util_php['delete_intermediate_explanation']),
after add
// Watermarking Mod
'delback' => array('delback', $lang_util_php['delete_back'], $lang_util_php['delete_back_explanation']),
// End Mod



find
function del_orphans()
before add
// Watermarking Mod
function del_back()
{
    global $picturetbl, $CONFIG, $lang_util_php;
    $albumid = $_POST['albumid'];

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

    $i = 0;
    while ($i < $num) {
        $pid = mysql_result($result, $i, "pid");
        $back = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . $CONFIG['orig_pfx'] . mysql_result($result, $i, "filename");

        if (file_exists($back)) {
if(unlink($back)){
                printf($lang_util_php['main_success'], $back);
                print '!<br>';
}
            } else {
                printf($lang_util_php['error_rename'], $back);
            }
        ++$i;
    }
}



find
function update_thumbs()
and replace the whole function with:
// Watermarking mod
function update_thumbs()
{
set_time_limit(3600);
    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);
$watermark="";

    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) {
$imagepath=mysql_result($result, $i, "filepath");
$imagefilename=mysql_result($result, $i, "filename");
$orig=$CONFIG['fullpath'] . $imagepath . $CONFIG['orig_pfx'] . $imagefilename;
        $image = $CONFIG['fullpath'] . $imagepath . $imagefilename;
$work_image = $image;
$orig_true='false';
if (file_exists($orig)) {
$work_image=$orig;
$orig_true='true';
}
else
$work_image=$image;
        if ($updatetype == 0 || $updatetype == 2) {
            $thumb = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . $CONFIG['thumb_pfx'] . mysql_result($result, $i, "filename");

            if (resize_image($work_image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false")) {
                print $thumb .' '. $lang_util_php['updated_succesfully'] . '!<br />';
                my_flush();
            } else {
                print $lang_util_php['error_create'] . ':$thumb<br />';
                my_flush();
            }
        }

        if ($updatetype == 1 || $updatetype == 2 || $updatetype == 3)
{
            $normal = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . $CONFIG['normal_pfx'] . mysql_result($result, $i, "filename");
            if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized')
{$watermark="true";}
else
{$watermark="false";}
            $imagesize = getimagesize($work_image);
            if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'])
{
                if (resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark))
{
                    print $normal . $lang_util_php['updated_succesfully'] . '!<br />';
                    my_flush();
}
                else
{
                    print $lang_util_php['error_create'] . ':$normal<br />';
                    my_flush();
}
}
}
       
        if ($updatetype == 3)
{
if ($orig_true == 'false')
{
if (copy($image, $orig))
{        
if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')
{
if (resize_image($orig, $image, $imagesize[0], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "true"))
{
             print $image . $lang_util_php['updated_succesfully'] . '!<br />';
             my_flush();
}
}
}
}
else
{
if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')
{
        $imagesize = getimagesize($orig);
if (resize_image($orig, $image, $imagesize[0], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "true"))
{
             print $image . $lang_util_php['updated_succesfully'] . '!<br />';
             my_flush();
}
}
else
{
if (copy($orig, $image))
{
                    print $orig . $lang_util_php['updated_succesfully'] . '!<br />';
                    my_flush();
}
}
}
}

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

    if ($startpic < $totalpics) {

        ?>
            <form action=<?php echo $phpself;
        
?>
method="post">
                    <input type="hidden" name="action" value="continuethumbs" />
                    <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
    
}
}
// End Watermarking mod



open delete.php
find
case 'picture':
few lines before find
echo "<tr><td colspan=\"6\" class=\"tablef\" align=\"center\">\n";
replace with
echo "<tr><td colspan=\"7\" class=\"tablef\" align=\"center\">\n";

find
<td class="tableh2" align="center"><b>{$lang_delete_php['ns_pic']}</b></td>
after add
<td class="tableh2" align="center"><b>{$lang_delete_php['orig_pic']}</b></td>

find
<tr><td><b>T</b></td><td>:</td><td><?php echo $lang_delete_php['thumb_pic'?></td></tr>
before add
<tr><td><b>O</b></td><td>:</td><td><?php echo $lang_delete_php['orig_pic'?></td></tr>

find
function delete_picture($pid)
in function find
$files = array($dir . $file, $dir . $CONFIG['normal_pfx'] . $file, $dir . $CONFIG['thumb_pfx'] . $file);
replace with
$files = array($dir . $file, $dir . $CONFIG['normal_pfx'] . $file, $dir . $CONFIG['thumb_pfx'] . $file, $dir . $CONFIG['orig_pfx'] . $file);


TheGamer1701

okay, you're almost done.

open editpics.php
find
$files=array($dir.$file, $dir.$CONFIG['normal_pfx'].$file, $dir.$CONFIG['thumb_pfx'].$file);
replace with
$files=array($dir.$file, $dir.$CONFIG['normal_pfx'].$file, $dir.$CONFIG['thumb_pfx'].$file, $dir.$CONFIG['orig_pfx'].$file);


open searchnew.php
find
if (strncmp($file, $CONFIG['thumb_pfx'], strlen($CONFIG['thumb_pfx'])) != 0 && strncmp($file, $CONFIG['normal_pfx'], strlen($CONFIG['normal_pfx'])) != 0 && $file != 'index.html')
replace with
if (strncmp($file, $CONFIG['orig_pfx'], strlen($CONFIG['orig_pfx'])) != 0 && strncmp($file, $CONFIG['thumb_pfx'], strlen($CONFIG['thumb_pfx'])) != 0 && strncmp($file, $CONFIG['normal_pfx'], strlen($CONFIG['normal_pfx'])) != 0 && $file != 'index.html')


remove or rename file
include/picmgmt.inc.php

make new file include/picmgmt.inc.php
add
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.2                                            //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002-2004 Gregory DEMAR                                     //
// http://www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// (http://coppermine.sf.net/team/)                                          //
// see /docs/credits.html for details                                        //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// (at your option) any later version.                                       //
// ------------------------------------------------------------------------- //
// CVS version: $Id: picmgmt.inc.php,v 1.8 2004/07/27 13:58:04 oddeveloper Exp $
// ------------------------------------------------------------------------- //

// Add a picture to an album
function add_picture($aid$filepath$filename$title ''$caption ''$keywords ''$user1 ''$user2 ''$user3 ''$user4 ''$category 0$raw_ip ''$hdr_ip '',$iwidth=0,$iheight=0)
{
    global 
$CONFIG$ERROR$USER_DATA$PIC_NEED_APPROVAL;
    global 
$lang_errors;

    
$image $CONFIG['fullpath'] . $filepath $filename;
    
$normal $CONFIG['fullpath'] . $filepath $CONFIG['normal_pfx'] . $filename;
    
$thumb $CONFIG['fullpath'] . $filepath $CONFIG['thumb_pfx'] . $filename;
    
$orig $CONFIG['fullpath'] . $filepath $CONFIG['orig_pfx'] . $filename;
$work_image $image;
    if (!
is_known_filetype($image)) {
        return 
false;
    } elseif (
is_image($filename)) {
if (!file_exists($orig) && $CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original'))  {
// if copy of full_sized doesn't exist and if watermark enabled and if fullsized pic watermark=true -> then we need a backup
if (!copy($image$orig))
                return 
false;
else
$work_image $orig;
}
        if (!
file_exists($thumb)) {
            if (!
resize_image($work_image$thumb$CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false"))
                return 
false;
        }
        
$imagesize getimagesize($work_image);
        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 (!resize_image($work_image$normal$CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "true"))
                
return false;
}
else {
if (!resize_image($work_image$normal$CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false"))
            return 
false;
}
}
/*else {
if (!resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false"))
                return false;

}*/
        
if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original'){
if (!resize_image($work_image$image$imagesize[0], $CONFIG['thumb_method'], 'orig''true'))
                
return false;
}
    } else {
        
$imagesize[0] = $iwidth;
        
$imagesize[1] = $iheight;
    }


    
$image_filesize filesize($image);
    
$total_filesize is_image($filename) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);


    
// Test if disk quota exceeded
    
if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota']) {
        
$result cpg_db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}{$CONFIG['TABLE_ALBUMS']} WHERE  {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT USER_ID) . "'");
        
$record mysql_fetch_array($result);
        
$total_space_used $record[0];
        
mysql_free_result($result);

        if (((
$total_space_used $total_filesize)>>10) > $USER_DATA['group_quota'] ) {
            @
unlink($image);
            if (
is_image($image)) {
                @
unlink($normal);
                @
unlink($thumb);
            }
            
$msg strtr($lang_errors['quota_exceeded'], array('[quota]' => ($USER_DATA['group_quota']),
                
'[space]' => ($total_space_used >> 10)));
            
cpg_die(ERROR$msg__FILE____LINE__);
        }
    }
    
// Test if picture requires approval
    
if (GALLERY_ADMIN_MODE) {
        
$approved 'YES';
    } elseif (!
$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT USER_ID) {
        
$approved 'YES';
    } elseif (!
$USER_DATA['pub_upl_need_approval']) {
        
$approved 'YES';
    } else {
        
$approved 'NO';
    }
    
$PIC_NEED_APPROVAL = ($approved == 'NO');
    
// User ID is now recorded when in admin mode (casper)
    
$user_id USER_ID;
    
$usernameUSER_NAME;
    
$query "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip) VALUES ('', '$aid', '" addslashes($filepath) . "', '" addslashes($filename) . "', '$image_filesize', '$total_filesize', '{$imagesize[0]}', '{$imagesize[1]}', '" time() . "', '$user_id', '$username','$title', '$caption', '$keywords', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip')";
    
$result cpg_db_query($query);

    return 
$result;
}

define("GIS_GIF"1);
define("GIS_JPG"2);
define("GIS_PNG"3);

// Add 'edit' directory if it doesn't exist
// Set access to read+write only
if (!is_dir($CONFIG['fullpath'].'edit')) {
    
$cpg_umask umask(0);
    @
mkdir($CONFIG['fullpath'].'edit',0666);
    
umask($cpg_umask);
    unset(
$cpg_umask);
}

/**
* resize_image()
*
* Create a file containing a resized 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
* @return 'true' in case of success
*/
function resize_image($src_file$dest_file$new_size$method$thumb_use$watermark="false")
{
    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 && ($method == 'gd1' || $method == 'gd2')) {
        
$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($ratio1.0);
if ($thumb_use == 'orig'$ratio=1.0;
    
$destWidth = (int)($srcWidth $ratio);
    
$destHeight = (int)($srcHeight $ratio);
    
// Method for thumbnails creation
    
switch ($method) {
        case 
"im" :
            if (
preg_match("#[A-Z]:|\\\\#Ai"__FILE__)) {
                
// get the basedir, remove '/include'
                
$cur_dir substr(dirname(__FILE__), 0, -8);
                
$src_file '"' $cur_dir '\\' strtr($src_file'/''\\') . '"';
                
$im_dest_file str_replace('%''%%', ('"' $cur_dir '\\' strtr($dest_file'/''\\') . '"'));
            } else {
                
$src_file escapeshellarg($src_file);
                
$im_dest_file str_replace('%''%%'escapeshellarg($dest_file));
            }

            
$output = array();
$anno_txt="";
$annotate="";

            
/*
             * Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files.
             * By Aditya Mooley <aditya@sanisoft.com>
             */

                
$cmd "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} $annotate $src_file $im_dest_file";
exec ($cmd$output$retval);
if ($watermark == "true"){
$cmd "{$CONFIG['impath']}composite -dissolve {$CONFIG['watermark_transparency']} -gravity {$CONFIG['where_put_watermark']} {$CONFIG['watermark_file']} $im_dest_file $im_dest_file";
exec ($cmd$output$retval);
            
}

            if (
$retval) {
                
$ERROR "Error executing ImageMagick - Return value: $retval";
                if (
$CONFIG['debug_mode']) {
                    
// Re-execute the command with the backtit operator in order to get all outputs
                    // will not work is safe mode is enabled
                    
$output = `$cmd 2>&1`;
                    
$ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><font size=\"2\">" nl2br(htmlspecialchars($cmd)) . "</font></div>";
                    
$ERROR .= "<br /><br /><div align=\"left\">The convert program said:<br /><font size=\"2\">";
                    
$ERROR .= nl2br(htmlspecialchars($output));
                    
$ERROR .= "</font></div>";
                }
                @
unlink($dest_file);
                return 
false;
            }
            break;

        case 
"gd1" :
            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 (
$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 imagecreate($destWidth$destHeight);
            
imagecopyresized($dst_img$src_img0000$destWidth, (int)$destHeight$srcWidth$srcHeight);
            
imagejpeg($dst_img$dest_file$CONFIG['jpeg_qual']);
            
imagedestroy($src_img);
            
imagedestroy($dst_img);
            break;

        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;
            }
            
$dst_img imagecreatetruecolor($destWidth$destHeight);
            
imagecopyresampled($dst_img$src_img0000$destWidth, (int)$destHeight$srcWidth$srcHeight);
            
if ($watermark == "true"){
$logoImage ImageCreateFromPNG($CONFIG['watermark_file']); 
    $logoW ImageSX($logoImage); 
    $logoH ImageSY($logoImage); 
    //where is the watermark displayed... 
    $pos $CONFIG['where_put_watermark']; 
if ($pos == "northwest") { 
$src_x 5;  
$src_y 5
} else if ($pos == "northeast") { 
$src_x $destWidth - ($logoW 5); 
$src_y 5
} else if ($pos == "southwest") { 
$src_x 5
$src_y $destHeight - ($logoH 5); 
} else if ($pos == "southeast") { 
$src_x $destWidth - ($logoW 5); 
$src_y $destHeight - ($logoH 5); 
} else if ($pos == "center") { 
$src_x = ($destWidth/2) - ($logoW/2); 
$src_y = ($destHeight/2) - ($logoH/2); 


// no, we don't support that in the script, overkill... just make a transparentbkg png and don't be so lazy
//imagecolortransparent($logoImage, imagecolorat($logoImage, $CONFIG['watermark_transparency_featherx'], $CONFIG['watermark_transparency_feathery']));
imagealphablending($dst_imgTRUE);
imagecolortransparent($logoImageimagecolorat($logoImage$CONFIG['watermark_transparency_featherx'], $CONFIG['watermark_transparency_feathery']));
ImageCopyMerge($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH,$CONFIG['watermark_transparency']); //$dst_x,$dst_y,0,0,$logoW,$logoH); 
}
imagejpeg($dst_img$dest_file$CONFIG['jpeg_qual']);
            
imagedestroy($src_img);
            
imagedestroy($dst_img);
            break;
    }
    
// Set mode of uploaded picture
    
chmod($dest_fileoctdec($CONFIG['default_file_mode']));
    
// We check that the image is valid
    
$imginfo getimagesize($dest_file);
    if (
$imginfo == null) {
        
$ERROR $lang_errors['resize_failed'];
        @
unlink($dest_file);
        return 
false;
    } else {
        return 
true;
    }
}
?>

bloodynipples


Veseliq

The other plugin didnt work for me - I'll try it within 2-3 hours and post the results  ;)

Joachim Müller

Just to clarify: it's not a plugin, it's a mod. A plugin uses the plugin API that comes with cpg1.4.x - this mod doesn't.

mrandall131

I'm very interested in this mod.  Did you ever get it installed?  Does this work without errors?

Thanks in advance.

ausfuzzy

hi
I'am new to this forum
I have tried this mod and i get no errors, but it doesnt put any watermarks on any images, so i think its not quite all there yet.
it can always get worst

bloodynipples

I also spent a good amount of time working on this last night and could not get it to work.  As you said, there are no errors, but it just doesn't watermark images.  I also noticed the admin pannel controls do not work as they should.  The options for "location of watermark" and "what images to watermark"  do not display as pull-down menus as expected, they display as the defaults - yes/no radio buttons.

I believe it is not completely compatable with 1.4.x and I am unsure if it will get there from here.  TheGamer1701 and others are currently working on a watermarking plugin.  Yes, a plugin not a mod. 

http://cpg-contrib.org/thumbnails.php?album=10

cheenamalai

I need to watermark my images upon uploading can this accomplish it?

Stramm

I haven't checked this version of the watermark mod so I can't say where it's problems are. Still my orig version works and is ported to 1.4x for quite some time (I just haven't it published as stand alone). You'll have to install my modpack. The difference between my watermark and the plugins (at least I think so) is that plugins watermark on the fly. Means they put heat on the server each time a pic gets displayed. So if you have some visits a day it's not recommended to use that but a permanent watermark as the one here. The advantage of that watermark solution is that it's saving a backup file. So you can undo the watermark if you once don't like it anymore.
I didn't open a standalone 1.4x watermark therad caujse I've written a good bunch of mods. And maintaining all the threads with a compatibility version to all the other mods is plain to much work for me.
So I still recommend the modpack. It has a lot of good functionallity. If you haven't seen the 'better thumbs' (thumb sharpening and cropping)... that's really worth a try. The minithumbs are cool too... and if you use category thumbs, then the mini thumbs may be from interest as well. They don't html reduce the cat preview pic but generate new thumbs that have exact the size you want to have for your category lead images. No fuzzy pics anymore but crystal clear images

Enough talkin.. if there's really (I mean really) need for the standalone version I might open a thread for it but I think I'm not able to pet the thread or give much support

cheenamalai

So your saying that if i install your modpack it will give me capability to watermark my images automatically upon uploading while giving me the benefits of more clearer thumbnails?  ??? I am using 1.4x and i need to know what can i do to watermark my images upon just an upload so i dont have to go to photoshop to water mark images one by one.  :D

If you could provide me links to water mark mod and your thumbnail mod. I would appreciate it. Also i am looking for BBCODES for either [IMG] tags or the image link it self.

My gallery is located here: http://www.pakistaniforcesforum.com/gallery

Thank you very much.

cheenamalai

Stramm i think your busy or you haven't read my post.

So is there anybody else who can support me over the post i made above?

Thanks.


cheenamalai


Stramm

best is not to send me unrequested PMs. That's something you agreed on when you signed up here. And you should ask your questions in the related thread instead here...

short answer... I'm quoting the 2nd line in the first post of the modpack thread
For now I've added bridge files for PhpBB 2.0.18, 19 and SMF 1.0x

cheenamalai

So i can't bridge with IPB if i have done your mod on my coppermine?

Stramm

it's a commercial software. I don't know it and can't write/ modify a brisge for it. There are only a few changes necessary but for that bridge you're on your own

cheenamalai

Well could you give me guidance on how to bridge it on my own? Since i am not capable of doing that.