New GD Functions for fullsize image HELP Please New GD Functions for fullsize image HELP Please
 

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

New GD Functions for fullsize image HELP Please

Started by idotcom, December 15, 2003, 12:47:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

idotcom

Hi,

I have written a php function that goes through a series of GD functions to add my copyright text to images when viewing fullsize image. I know the function works because i have tested it on its own.

I have been trying to figure out where it needs to go..

I assumed it needs to go in the displayimage.php file but where?

I have it in now... but when the popup (new window) with the full size images opens, it just shows a bunch of weird stuff. I'm not sure, but I think there may be some other function(s) interfering.

I would appreciate any input on this..


heres the code..

showcopyright($file = $pic_url);

function showcopyrights($file = "none")
{

    $size = getimagesize($file);
    $src = imagecreatefromjpeg("$file");
    $twidth = $size[0];
    $theight = $size[1];
    $img = imagecreatetruecolor($twidth,$theight);

    $layer2w = $twidth / 1.8;
    $layer2h = ($theight / 9.38 ) * 9;

    $layer1w = $twidth / 1.8;
    $layer1h = ($theight / 9.4) * 9;

    $text_percent = ($twidth / $theight) * 100;
    $text_size = $text_percent / 12;

    $black = imagecolorallocate ($img, 0, 0, 0);
    $white = imagecolorallocate ($img, 255, 255, 255);

        Header("Content-type: image/jpeg");

        imagecopyresampled($img,$src,0,0,0,0,$twidth,$theight,imagesx($src),imagesy($src));


        imagettftext($img, $text_size, 0, $layer2w, $layer2h, $black, "verdanab.ttf","Copyright (c) 2003");

        imagettftext($img, $text_size, 0, $layer1w, $layer1w, $white, "verdanab.ttf", "Copyright (c) 2003");

        imagejpeg($img);
        imagedestroy($img);

}


Thanks

Joachim Müller

take a look at the watermark hack and how this is done - you can't just simply put the image you created into displayimage.php, as this file usually refers to a static image, not one you create on the fly.
Your solution is not recommended, because it consumes huges ressources, slows the gallery down and makes the images run twice through the compression algorhythm for jpegs.
I recommend adding the watermark before you upload your pics to the server (there are a lot of free scripts that can do this).
Please bear in mind that we can not support any hacks you create - although we appreciate users sharing working hacks, you can't just copy-and-paste some image manipulation code from somewhere else and ask us to put it into coppermine core code for you. We know how coppermine works, but we can't do your work - if you need a feature and you're ready to code it - fine. If you encounter errors - look into it more deeply.

GauGau