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]   Go Down

Author Topic: different watermarks for high and medium quality pictures?  (Read 3430 times)

0 Members and 1 Guest are viewing this topic.

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
different watermarks for high and medium quality pictures?
« on: April 14, 2012, 04:57:03 am »

I know I'm making a lot of topics lately, but well, I just like to chance a lot of my coppermine ;P

my question is: is that a way use one watermark for pictures with width over than 1000 px and another watermark for pictures with width lower than 1000px?

I know it should be around include/picmgmt.inc.php file, but don't know who to do it

thanks
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: different watermarks for high and medium quality pictures?
« Reply #1 on: April 14, 2012, 06:43:47 pm »

If you just want to use a smaller version of the same watermark image for the medium size pics then just use the downsize function (config).

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Re: different watermarks for high and medium quality pictures?
« Reply #2 on: April 14, 2012, 06:49:52 pm »

If you just want to use a smaller version of the same watermark image for the medium size pics then just use the downsize function (config).

it's not the same, they're different
they're on the same place of the image (bottom left), just the watermark image that it's different
Logged

Tankertom

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 73
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: different watermarks for high and medium quality pictures?
« Reply #4 on: April 14, 2012, 08:08:53 pm »

working, thank you soooo much

[I needed to change it a little, but it worked, thanks ^^]
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: different watermarks for high and medium quality pictures?
« Reply #5 on: April 16, 2012, 03:00:45 pm »

I needed to change it a little

To help other users with the same question, please
resolve your thread. Don't just post "I have found the answer", but tell others what you actually did to solve your issues. Posting a link to the page where you found the answer might help. Describing what you did might help as well.
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: different watermarks for high and medium quality pictures?
« Reply #6 on: May 06, 2012, 07:48:14 pm »

sorry, just saw that post now

I'm using gd2, so it's after case "gd2" :

Quote
        case "gd2" :
            if (!function_exists('imagecreatefromjpeg')) {
                return array('error' => 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', 'halt_upload' => 1);
            }
            if (!function_exists('imagecreatetruecolor')) {
                return array('error' => 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the admin page', 'halt_upload' => 1);
            }
            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;
                return array('error' => $ERROR);
            }
            if ($imginfo[2] == GIS_GIF) {
                $dst_img = imagecreate($destWidth, $destHeight);
            } else {
                $dst_img = imagecreatetruecolor($destWidth, $destHeight);
                if ($imginfo[2] == GIS_PNG) {
                    imagealphablending($dst_img, false);
                }
            }
            imagecopyresampled($dst_img, $src_img, 0, 0, $xOffset, $yOffset, (int)$destWidth, (int)$destHeight, $srcWidth, $srcHeight);
            touch($dest_file);
            $fh=fopen($dest_file,'w');
            fclose($fh);

            //sharpen the thumb
            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";
            }
           
            //pic the right watermark
            $tamanhoMax = 1000;      
            if (($imagesize[1] <= $tamanhoMax) || ($imagesize[0] <= $tamanhoMax)) {
                $watermark_file = 'water/tagMQ.png';
            } else {
                $watermark_file = $CONFIG['watermark_file'];
            }

            if ($watermark == "true" || $media_type != "false") {
                //shrink watermark on intermediate images -> If I had known that this is that �%&#38;# with the transparency preserve... grrr
                $wm_normal = (int)$CONFIG['reduce_watermark'];
                if ($wm_normal > $destWidth ) {
                    $wm_resize = $destWidth / $wm_normal;
                    //load the original, huge sized logo (the one we want to size down)
                    $temp_logoImage = ImageCreateFromPNG($watermark_file);
                    //get it's size
                    $temp_logoW = ImageSX($temp_logoImage);
                    $temp_logoH = ImageSY($temp_logoImage);

                    //calculate new size
                    $logoW = (int)($temp_logoW * $wm_resize);
                    $logoH = (int)($temp_logoH * $wm_resize);
                    //we create a new, resized logo
                    $logoImage = imagecreatetruecolor($logoW, $logoH);

                    //just to be sure that transparency gets preserved
                    imagealphablending($logoImage, FALSE);
                    imagealphablending($temp_logoImage, TRUE);

                    //now copy and resize the big one into the temp resized img
                    imagecopyresampled($logoImage, $temp_logoImage, 0, 0, 0, 0, (int)$logoW, (int)$logoH, $temp_logoW, $temp_logoH);

                    //we do not need the temp (huge) watermark anymore
                    imagedestroy($temp_logoImage);

                } else { // shrink not enabled or no intermediate...
                    $logoImage = ImageCreateFromPNG($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']));
                ImageCopy($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH);
            }

            if ($imginfo[2] == GIS_PNG) {
                imagesavealpha($dst_img, true);
                imagepng($dst_img, $dest_file, round((100 - $CONFIG['jpeg_qual']) / 10));
            } else {
                imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
            }
            imagedestroy($src_img);
            imagedestroy($dst_img);
            break;
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.