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 ... 9 10 11 12 [13] 14 15 16 17 ... 26   Go Down

Author Topic: Permanant watermark with undo possibility (GD2+IM working!) + better admin tools  (Read 410185 times)

0 Members and 2 Guests are viewing this topic.

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt

please post on the modpack board if you have questions related to the modpack. This thread deals with just the watermark mod.

Your watermark.png is corrupted... reupload a working watermark image in png format

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me

Thank you.

Apologies for posting in the wrong thread.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

bibendum

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #242 on: November 13, 2007, 11:09:59 pm »

Hi
Can i apply this wonderfull mod to cpg 1.4.14 ?
Thanks
Logged

Gigatek

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #243 on: November 14, 2007, 04:49:29 am »

Anyone with this error in upload.php... I know it comes from picmgmt but I installed and followed the instructions twice with no sucess... thanks..


Code: [Select]
= str_replace('%', '%%', escapeshellarg($dest_file)); } $output = array(); /* * Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files. * By Aditya Mooley */ if ($sharpen==1 && $CONFIG['enable_unsharp']==1) { $unsharp_mask = " -unsharp ".$CONFIG['unsharp_radius']."x".sqrt($CONFIG['unsharp_radius'])."+".($CONFIG['unsharp_amount']/100)."+".($CONFIG['unsharp_threshold']/100)." "; } else $unsharp_mask = ""; if (eregi("win",$_ENV['OS'])) { $cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} ".$resize_commands." ".$unsharp_mask." ".str_replace("\\","/" ,$src_file )." ".str_replace("\\","/" ,$im_dest_file ); exec ("\"$cmd\"", $output, $retval); } else { $cmd = "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} ".$resize_commands." ".$unsharp_mask." $src_file $im_dest_file"; exec ($cmd, $output, $retval); } if ($media_type != "false"){ //if a manual thumb gets generated we watermark the thumb with the media type //we now need to get the absolute path to the thumb watermark files $path_parts = pathinfo($CONFIG['watermark_file']); $CONFIG['watermark_file'] = $path_parts["dirname"]."/wm_".$media_type.".png"; } if ($watermark == "true" || $media_type != "false"){ if (eregi("win",$_ENV['OS'])) { $cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."composite\" -dissolve {$CONFIG['watermark_transparency']} -gravity {$CONFIG['where_put_watermark']} \"{$CONFIG['watermark_file']}\" ".str_replace("\\","/" ,$im_dest_file )." ".str_replace("\\","/" ,$im_dest_file ); exec ("\"$cmd\"", $output, $retval); } else { $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 backtick operator in order to get all outputs // will not work is safe mode is enabled $output = `$cmd 2>&1`; $ERROR .= "


Cmd line :
" . nl2br(htmlspecialchars($cmd)) . "
"; $ERROR .= "


The convert program said:
"; $ERROR .= nl2br(htmlspecialchars($output)); $ERROR .= "
"; } @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_img, 0, 0, $xOffset, $yOffset, (int)$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 admin page', __FILE__, __LINE__); } if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 1) $src_img = imagecreatefromgif($src_file); elseif ($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; } if ($imginfo[2] == GIS_GIF) $dst_img = imagecreate($destWidth, $destHeight); else $dst_img = imagecreatetruecolor($destWidth, $destHeight); imagecopyresampled($dst_img, $src_img, 0, 0, $xOffset, $yOffset, (int)$destWidth, (int)$destHeight, $srcWidth, $srcHeight); if ($sharpen==1 && $CONFIG['enable_unsharp']==1) { UnsharpMask($dst_img, $CONFIG['unsharp_amount'], $CONFIG['unsharp_radius'], $CONFIG['unsharp_threshold']); } if ($media_type != "false"){ //if a manual thumb gets generated we watermark the thumb with the media type //we now need to get the absolute path to the thumb watermark files $path_parts = pathinfo($CONFIG['watermark_file']); $CONFIG['watermark_file'] = $path_parts["dirname"]."/wm_".$media_type.".png"; } if ($watermark == "true" || $media_type != "false"){ $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); } imagealphablending($dst_img, TRUE); imagecolortransparent($logoImage, imagecolorat($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); ImageCopy($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH); //$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_file, octdec($CONFIG['default_file_mode'])); //silence the output in case chmod is disabled // 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; } } function UnsharpMask($img, $amount, $radius, $threshold)
« Last Edit: November 14, 2007, 03:58:18 pm by PYAP »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #244 on: November 14, 2007, 07:52:48 am »

reupload picmgmnt.inc.php. Make sure you overwrite the original... or rename the original file to something else and then upload

Gigatek

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #245 on: November 14, 2007, 12:42:00 pm »

reupload picmgmnt.inc.php. Make sure you overwrite the original... or rename the original file to something else and then upload

Downloaded it again and it worked... thanks
Logged

bibendum

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #246 on: November 16, 2007, 09:59:06 am »

Hi
Can i apply this wonderfull mod to cpg 1.4.14 ?
Thanks


Hi
I will answer myself !!!
It's working on cpg 1.4.14  ;)
Thanks
Logged

Qayyom

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 52
    • www.PICSnCLIPS.net
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #247 on: November 17, 2007, 07:06:59 am »

Hi

Is it Possible?

I want to apply watermark on all previous images.

I've 1000+ pics collection on my site.

If possible then how?
Logged
Qayyom Ashraf .:|:. Karachi-PK
 *Image Removed*

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #248 on: November 17, 2007, 09:40:08 am »

don't be so lazy and read the first post of this thread

Bastox

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #249 on: November 25, 2007, 06:52:45 am »

Hi Stramm...

I've just installed your pack. Thank's it's very good. But I think you forget something in admin.php.

In the admin pannel, There is no way to change the prefix "orig_"
Nothing in admin.php, nothing in lang/english.php...

The watermarking is a way to "secure" the pictures. If everyone can acces them because you've got just to put "orig_" before the name of the picture the MOD becaume less usefull.

Cheers.

Logged

TurboSc

  • Coppermine newbie
  • Offline Offline
  • Posts: 4

Hey Stramm,

I've read every post ( including the first one :P ) and I'm having some issues with the watermark function.

Please also keep in mind I'm pretty much a newb to all of this but I followed your directions...

I replaced picmgmt.inc.php and ran update.php but once I go into the config menu, there is no sign of watermark options etc.

I tried replacing it with the newer file from your modpack, ran update.php, still no luck.

I replaced lang/english.php from your modpack and ran update with "some" success, the watermark options show, but it seems the bottom of the config menu is broken ( the buttons to save config, etc are missing ) Under watermarking it also says "invalid options"

I'm running Coppermine Photo Gallery 1.4.14 (stable) with no other plugins, I just need watermarking to work basically, hehe... do I need to replace the /lang/english.php or update it?

if so what do I need to add to this file to get watermarking to work. Thank you in advance.

- Sunny
Logged

TurboSc

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #251 on: November 25, 2007, 08:52:35 am »

Hey Stramm,

I've read every post ( including the first one :P ) and I'm having some issues with the watermark function.

Please also keep in mind I'm pretty much a newb to all of this but I followed your directions...

I replaced picmgmt.inc.php and ran update.php but once I go into the config menu, there is no sign of watermark options etc.

I tried replacing it with the newer file from your modpack, ran update.php, still no luck.

I replaced lang/english.php from your modpack and ran update with "some" success, the watermark options show, but it seems the bottom of the config menu is broken ( the buttons to save config, etc are missing ) Under watermarking it also says "invalid options"

I'm running Coppermine Photo Gallery 1.4.14 (stable) with no other plugins, I just need watermarking to work basically, hehe... do I need to replace the /lang/english.php or update it?

if so what do I need to add to this file to get watermarking to work. Thank you in advance.

- Sunny

I'm an idiot, and I've since reread your thread and gotten everything working. Please forgive me :P

I did read however somewhere within those 13 pages of information a way to change the padding of the watermark placement... could you help me locate the place to make that happen?

What I'm trying to do actually is to get rid of it, because my watermark needs to sit flush top right with no pixel padding at all... Thanks in advance.
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #252 on: November 25, 2007, 10:21:05 am »

Hi Stramm...

I've just installed your pack. Thank's it's very good. But I think you forget something in admin.php.

In the admin pannel, There is no way to change the prefix "orig_"
Nothing in admin.php, nothing in lang/english.php...

The watermarking is a way to "secure" the pictures. If everyone can acces them because you've got just to put "orig_" before the name of the picture the MOD becaume less usefull.

Cheers.



It's not meant to be changed (yet) cause it's not tested if it'll work. If you dare to try, you can edit that in the db (table config). Also there's a description (somewhere, I do not remember, either in a modpack or one of the watermark mod threads [1.3 or 1.4]) how to edit the code to prevent the script from generating the orig backup.

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #253 on: November 25, 2007, 10:29:42 am »

I'm an idiot, and I've since reread your thread and gotten everything working. Please forgive me :P

I did read however somewhere within those 13 pages of information a way to change the padding of the watermark placement... could you help me locate the place to make that happen?

What I'm trying to do actually is to get rid of it, because my watermark needs to sit flush top right with no pixel padding at all... Thanks in advance.

You have to do some code changes in picmgmnt.inc.php. Please make sure you have an up to date one (download the modpack and get it there). Then find
Code: [Select]
    $pos = $CONFIG['where_put_watermark'];and below replace all occurances of '5' (that's the actual padding in px) with the padding you desire ('0' in your case)

bones

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
  • Live Free, or Die.
    • Bikers-n-Outlaws.com - The Biker's Internet Connection

I've applied this mod and no problems whatsoever.

A big THANKS to everyone responsible for this mod!

(http://bikers-n-outlaws.com/gallery-stats.gif)
Logged

Bastox

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #255 on: November 30, 2007, 08:00:02 am »

It's not meant to be changed (yet) cause it's not tested if it'll work. If you dare to try, you can edit that in the db (table config). Also there's a description (somewhere, I do not remember, either in a modpack or one of the watermark mod threads [1.3 or 1.4]) how to edit the code to prevent the script from generating the orig backup.
Tested... That works work for me. I think you can add a option forthe next version...  ;)
After a double check...

I can test that as well if you want
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #256 on: November 30, 2007, 09:03:54 am »

Tested... That works work for me. I think you can add a option forthe next version...  ;)
After a double check...

I can test that as well if you want

it's already added to the upcoming  version 1.5
the custom thumb tool you link to is from march 2006, a new, improved version has been released since that (within the modpack)

Hayvosh

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 11
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #257 on: December 19, 2007, 11:33:18 pm »

I might have missed something during the installation, I've tried to install this two times but I get this same error anyhow.
What could I be doing wrong?

Code: [Select]
$src_file = escapeshellarg($src_file); $im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file)); } $output = array(); /* * Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files. * By Aditya Mooley */ if ($sharpen==1 && $CONFIG['enable_unsharp']==1) { $unsharp_mask = " -unsharp ".$CONFIG['unsharp_radius']."x".sqrt($CONFIG['unsharp_radius'])."+".($CONFIG['unsharp_amount']/100)."+".($CONFIG['unsharp_threshold']/100)." "; } else $unsharp_mask = ""; if (eregi("win",$_ENV['OS'])) { $cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} ".$resize_commands." ".$unsharp_mask." ".str_replace("\\","/" ,$src_file )." ".str_replace("\\","/" ,$im_dest_file ); exec ("\"$cmd\"", $output, $retval); } else { $cmd = "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} ".$resize_commands." ".$unsharp_mask." $src_file $im_dest_file"; exec ($cmd, $output, $retval); } if ($media_type != "false"){ //if a manual thumb gets generated we watermark the thumb with the media type //we now need to get the absolute path to the thumb watermark files $path_parts = pathinfo($CONFIG['watermark_file']); $CONFIG['watermark_file'] = $path_parts["dirname"]."/wm_".$media_type.".png"; } if ($watermark == "true" || $media_type != "false"){ if (eregi("win",$_ENV['OS'])) { $cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."composite\" -dissolve {$CONFIG['watermark_transparency']} -gravity {$CONFIG['where_put_watermark']} \"{$CONFIG['watermark_file']}\" ".str_replace("\\","/" ,$im_dest_file )." ".str_replace("\\","/" ,$im_dest_file ); exec ("\"$cmd\"", $output, $retval); } else { $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 backtick operator in order to get all outputs // will not work is safe mode is enabled $output = `$cmd 2>&1`; $ERROR .= "

Cmd line :
" . nl2br(htmlspecialchars($cmd)) . "
"; $ERROR .= "

The convert program said:
"; $ERROR .= nl2br(htmlspecialchars($output)); $ERROR .= "
"; } @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_img, 0, 0, $xOffset, $yOffset, (int)$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 admin page', __FILE__, __LINE__); } if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 1) $src_img = imagecreatefromgif($src_file); elseif ($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; } if ($imginfo[2] == GIS_GIF) $dst_img = imagecreate($destWidth, $destHeight); else $dst_img = imagecreatetruecolor($destWidth, $destHeight); imagecopyresampled($dst_img, $src_img, 0, 0, $xOffset, $yOffset, (int)$destWidth, (int)$destHeight, $srcWidth, $srcHeight); if ($sharpen==1 && $CONFIG['enable_unsharp']==1) { UnsharpMask($dst_img, $CONFIG['unsharp_amount'], $CONFIG['unsharp_radius'], $CONFIG['unsharp_threshold']); } if ($media_type != "false"){ //if a manual thumb gets generated we watermark the thumb with the media type //we now need to get the absolute path to the thumb watermark files $path_parts = pathinfo($CONFIG['watermark_file']); $CONFIG['watermark_file'] = $path_parts["dirname"]."/wm_".$media_type.".png"; } if ($watermark == "true" || $media_type != "false"){ $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); } imagealphablending($dst_img, TRUE); imagecolortransparent($logoImage, imagecolorat($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); ImageCopy($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH); //$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_file, octdec($CONFIG['default_file_mode'])); //silence the output in case chmod is disabled // 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; } } function UnsharpMask($img, $amount, $radius, $threshold) { //////////////////////////////////////////////////////////////////////////////////////////////// //// //// p h p U n s h a r p M a s k //// //// Unsharp mask algorithm by Torstein H�nsi 2003. //// thoensi_at_netcom_dot_no. //// Please leave this notice. //// /////////////////////////////////////////////////////////////////////////////////////////////// if ($amount > 500) $amount = 500; $amount = $amount * 0.016; if ($radius > 50) $radius = 50; $radius = $radius * 2; if ($threshold > 255) $threshold = 255; $radius = abs(round($radius)); // Only integers make sense. if ($radius == 0) { return $img; imagedestroy($img); break; } $w = imagesx($img); $h = imagesy($img); $imgCanvas = imagecreatetruecolor($w, $h); $imgCanvas2 = imagecreatetruecolor($w, $h); $imgBlur = imagecreatetruecolor($w, $h); $imgBlur2 = imagecreatetruecolor($w, $h); imagecopy ($imgCanvas, $img, 0, 0, 0, 0, $w, $h); imagecopy ($imgCanvas2, $img, 0, 0, 0, 0, $w, $h); for ($i = 0; $i < $radius; $i++) { imagecopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); //center imagecopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h); imagecopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 ); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); imagecopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h); } for ($x = 0; $x < $w; $x++) { // each row for ($y = 0; $y < $h; $y++) { // each pixel $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); $rOrig = (($rgbOrig >> 16) & 0xFF); $gOrig = (($rgbOrig >> 8) & 0xFF); $bOrig = ($rgbOrig & 0xFF); $rgbBlur = ImageColorAt($imgCanvas, $x, $y); $rBlur = (($rgbBlur >> 16) & 0xFF); $gBlur = (($rgbBlur >> 8) & 0xFF); $bBlur = ($rgbBlur & 0xFF); $rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); ImageSetPixel($img, $x, $y, $pixCol); } } } imagedestroy($imgCanvas); imagedestroy($imgCanvas2); imagedestroy($imgBlur); imagedestroy($imgBlur2); return $img; } ?>, 0, 1, 1, $w - 1, $h - 1); // up left imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center imagecopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h); imagecopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 ); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); imagecopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h); } for ($x = 0; $x < $w; $x++) { // each row for ($y = 0; $y < $h; $y++) { // each pixel $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); $rOrig = (($rgbOrig >> 16) & 0xFF); $gOrig = (($rgbOrig >> 8) & 0xFF); $bOrig = ($rgbOrig & 0xFF); $rgbBlur = ImageColorAt($imgCanvas, $x, $y); $rBlur = (($rgbBlur >> 16) & 0xFF); $gBlur = (($rgbBlur >> 8) & 0xFF); $bBlur = ($rgbBlur & 0xFF); $rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); ImageSetPixel($img, $x, $y, $pixCol); } } } imagedestroy($imgCanvas); imagedestroy($imgCanvas2); imagedestroy($imgBlur); imagedestroy($imgBlur2); return $img; } ?> * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); ImageSetPixel($img, $x, $y, $pixCol); } } } } else{ for ($x = 0; $x < $w; $x++) { // each row for ($y = 0; $y < $h; $y++) { // each pixel $rgbOrig = ImageColorAt($img, $x, $y); $rOrig = (($rgbOrig >> 16) & 0xFF); $gOrig = (($rgbOrig >> 8) & 0xFF); $bOrig = ($rgbOrig & 0xFF); $rgbBlur = ImageColorAt($imgBlur, $x, $y); $rBlur = (($rgbBlur >> 16) & 0xFF); $gBlur = (($rgbBlur >> 8) & 0xFF); $bBlur = ($rgbBlur & 0xFF); $rNew = ($amount * ($rOrig - $rBlur)) + $rOrig; if($rNew>255){$rNew=255;} elseif($rNew<0){$rNew=0;} $gNew = ($amount * ($gOrig - $gBlur)) + $gOrig; if($gNew>255){$gNew=255;} elseif($gNew<0){$gNew=0;} $bNew = ($amount * ($bOrig - $bBlur)) + $bOrig; if($bNew>255){$bNew=255;} elseif($bNew<0){$bNew=0;} $rgbNew = ($rNew << 16) + ($gNew <<8) + $bNew; ImageSetPixel($img, $x, $y, $rgbNew); } } } imagedestroy($imgCanvas); imagedestroy($imgBlur); return $img; } //used for custom thumbs function crop_image($src_file, $dest_file, $new_size_w, $new_size_h, $xOffset, $yOffset) { 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 && $imageinfo[2] != GIS_PNG && $CONFIG['GIF_support'] == 0) { $ERROR = $lang_errors['gd_file_type_err']; return false; } switch ($CONFIG['thumb_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(); /* * Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files. * By Aditya Mooley */ $resize_commands = $new_size_w . "x" . $new_size_h . "+" . $xOffset . "+" . $yOffset; if (eregi("win",$_ENV['OS'])) { $cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality 100 -crop ".$resize_commands." ".str_replace("\\","/" ,$src_file )." ".str_replace("\\","/" ,$im_dest_file ); exec ("\"$cmd\"", $output, $retval); } else { $cmd = "{$CONFIG['impath']}convert -quality 100 -crop ".$resize_commands." $src_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 backtick operator in order to get all outputs // will not work is safe mode is enabled $output = `$cmd 2>&1`; $ERROR .= "

Cmd line :
" . nl2br(htmlspecialchars($cmd)) . "
"; $ERROR .= "

The convert program said:
"; $ERROR .= nl2br(htmlspecialchars($output)); $ERROR .= "
"; } @unlink($dest_file); return false; } else { return true; } break; case "gd2" : if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 1) $src_img = imagecreatefromgif($src_file); elseif ($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; } if ($imginfo[2] == GIS_GIF) $dst_img = imagecreate($new_size_w, $new_size_h); else $dst_img = imagecreatetruecolor($new_size_w, $new_size_h); imagecopyresampled($dst_img, $src_img, 0, 0, $xOffset, $yOffset, $new_size_w+$xOffset, $new_size_h+$yOffset, $new_size_w+$xOffset, $new_size_h+$yOffset); imagejpeg($dst_img, $dest_file, 100); imagedestroy($src_img); imagedestroy($dst_img); // Set mode of uploaded picture @chmod($dest_file, octdec($CONFIG['default_file_mode'])); //silence the output in case chmod is disabled // 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; } break; }// end switch } ?>
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #258 on: December 19, 2007, 11:41:00 pm »

reupload picmgmnt.inc.php

Hayvosh

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 11
Re: Permanant watermark with undo possibility (GD2+IM working!) + better admin t
« Reply #259 on: December 20, 2007, 12:46:41 am »

reupload picmgmnt.inc.php

Can I use the one 1.4.6 version or? Because that was the one I tried with earlier when it didnt work.
Logged
Pages: 1 ... 9 10 11 12 [13] 14 15 16 17 ... 26   Go Up
 

Page created in 0.037 seconds with 20 queries.