Jump to content

this image marker!


alwaysme

Recommended Posts

hi i got to install a watermark mod...however the background is not transparent!

 

its always black and ugly...the file is a png transparent file...i tried with every transparent png i have and all the same result

 

this is the code

/ begin watermark mod

					$is_image = (strpos($filedata['mimetype'], 'image/') !== false) ? true : false;
					if ($is_image)
					{
						require("includes/watermark/phpWatermark-0.3/phpWatermark.inc.php");
						require("includes/watermark/config.php");
						$wm = new watermark("files/".$filedata['physical_filename']);
						$wm->setPosition($watermark['position']);
						if ($watermark['type'] == 'text')
						{
							if ($watermark['text_color'] != 'auto')
							{
								$wm->setFixedColor($watermark['text_color']);
							}
							$wm->addWatermark($watermark['text'], "TEXT");
						}
						elseif ($watermark['type'] == 'image')
						{
							$wm->addWatermark($watermark['image'], "IMAGE");
						}

						$im = $wm->getMarkedImage();
						imagepng($im, "files/".$filedata['physical_filename']);
					}

					// end watermark mod

 

 

is it possible that php is responsible for tranparentcy?

 

Link to comment
Share on other sites

i find some code that i use to use on another script a long time ago....the watermark was an addon and it work really well....maybe we can use something from the code for the above to make it right??

 

$watermark_ok = 0;
if ($album_config['watermark_images'] == 1)
{
        $marktype = substr($album_config['watermark_source'], strlen($album_config['watermark_source']) - 4, 4);
        switch ( $marktype )
        {
                case '.png':
                        $nm = imagecreatefrompng($album_config['watermark_source']);
                        break;
                case '.gif':
                        $nm = imagecreatefromgif($album_config['watermark_source']);
                        break;
                case '.jpg':
                case 'jpeg':
                        $nm = imagecreatefromjpeg($album_config['watermark_source']);
                        break;
                default:
                        $nm = false;
        }

        if ( $nm )
        {
                $sx = imagesx($nm);
                $sy = imagesy($nm);

                switch ( $pic_filetype )
                {
                        case '.png':
                                $im = imagecreatefrompng(ALBUM_UPLOAD_PATH  . $thispic['pic_filename']);
                                break;
                        case '.gif':
                                $im = imagecreatefromgif(ALBUM_UPLOAD_PATH  . $thispic['pic_filename']);
                                break;
                        case '.jpg':
                        case 'jpeg':
                                $im = imagecreatefromjpeg(ALBUM_UPLOAD_PATH  . $thispic['pic_filename']);
                                break;
                        default:
                                $im = false;
                }

                if ( $im )
                {
                        $sx2 = imagesx($im);
                        $sy2 = imagesy($im);
                        imagecopymerge($im,$nm,($sx2 - $sx - 5), ($sy2 - $sy - 5), 0,0,$sx,$sy,40);

                        $watermark_ok = 1;
                }
        }
}

if ($watermark_ok)
{
        switch ( $pic_filetype )
        {
                case '.png':
                case '.gif':
                        header('Content-type: image/png');
                        imagepng($im);
                        break;
                default:
                        header('Content-type: image/jpeg');
                        imagejpeg($im);
                        break;
        }
}
else
{

 

the problem is i dont understand much  ??? :-[

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.