different watermarks for high and medium quality pictures? different watermarks for high and medium quality pictures?
 

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

different watermarks for high and medium quality pictures?

Started by alexandre596, April 14, 2012, 04:57:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

alexandre596

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

Stramm

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

Quote from: Stramm 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).

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


alexandre596

working, thank you soooo much

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

Αndré

Quote from: alexandre596 on April 14, 2012, 08:08:53 PM
I needed to change it a little

To help other users with the same question, please
Quote from: Joachim Müller on September 28, 2008, 12:46:26 PM
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.

alexandre596

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;