Jump to content

Search the Community

Showing results for tags 'cant get it to take new size'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. This script adds a text watermark to an image. No matter what number I put into this script under $fontsize = ? for changing the font size, it does not change when viewing the image. I've tried adding px and em to the number to see if that would help, but it made the images not show up altogether. Can anyone please help me? Here is the code: <?php function watermark_text($src_image,$watermarkstring,$watermark_location,$watermark_margin=0) { $file = $src_image; $size = getimagesize($file); $w = $size[0]; $h = $size[1]; $fontsize = 30; if(stristr($file,".jpg") || stristr($file,".jpeg")) { $image=@imagecreatefromjpeg($file); } else if(stristr($file,".png")) { $image = @imagecreatefrompng($file); } else { exit("Sorry, only *.jpg/*jpeg and *.png images are supported"); } $color = imagecolorallocate($image, 200, 200, 200); $xi = 0; $yi = 0; $strlen_watermark = strlen($watermarkstring); switch($watermark_location) { case "topleft": $x = $watermark_margin; $y = $watermark_margin; break; case "topright": $x = $size[0] - $fontsize * strlen($watermarkstring); $y = $watermark_margin; break; case "center": $x = $size[0]/2 - $fontsize * strlen($watermarkstring)/2; $y = $size[1]/2 - $fontsize ; break; case "bottomleft": $x = $watermark_margin; $y = $size[1] - $fontsize - $watermark_margin; break; case "bottomright": $x = $size[0] - $fontsize * strlen($watermarkstring); $y = $size[1] - $fontsize - $watermark_margin; break; default: $x = 0; $y = 0; break; } imagestring($image, $fontsize, $x, $y, "$watermarkstring", $color); if(stristr($file,".jpg") || stristr($file,".jpeg")) { header("Content-type: image/jpeg"); imagejpeg($image,NULL,100); } else if(stristr($file,".png")) { header("Content-type: image/png"); imagepng($image); } else { exit("Sorry, only *.jpg/*jpeg and *.png images supported"); } ImageDestroy($image); }//function ////////////////////////////////////////////////////////////////////////////////// function watermark_image($image_path_src,$image_path_watermark,$watermark_location,$watermark_margin=0) { if(stristr($image_path_src,".jpg") || stristr($image_path_src,".jpeg")) { $image=@imagecreatefromjpeg($image_path_src); } else if(stristr($image_path_src,".png")) { $image = @imagecreatefrompng($image_path_src); } else { exit("Sorry, only *.jpg/*jpeg and *.png images are supported"); } $size = getimagesize($image_path_src); $w = $size[0]; $h = $size[1]; $src_x = 0; $src_y = 0; if(preg_match("#\.png$#i",$image_path_watermark)) $watermark_image = imagecreatefrompng($image_path_watermark); else if(preg_match("#\.gif$#i",$image_path_watermark)) $watermark_image = imagecreatefromgif($image_path_watermark); else if(preg_match("#\.jpe*g$#i",$image_path_watermark)) $watermark_image = imagecreatefromjpeg($image_path_watermark); else exit("Sorry, only *.gif, *.jpg and *.png watermarks are supported"); $size_watermark = getimagesize($image_path_watermark); $dst_w = $src_w = $size_watermark[0]; $dst_h = $src_h = $size_watermark[1]; switch($watermark_location) { case "topleft": $x = $watermark_margin; $y = $watermark_margin; break; case "topright": $x = $size[0] - $size_watermark[0] - $config["watermark_margin"]; $y = $watermark_margin; break; case "center": $x = $size[0]/2 - $size_watermark[0]/2; $y = $size[1]/2 - $size_watermark[1]/2; break; case "bottomleft": $x = $watermark_margin; $y = $size[1] - $size_watermark[1] - $watermark_margin; break; case "bottomright": $x = $size[0] - $size_watermark[0] - $watermark_margin; $y = $size[1] - $size_watermark[1] - $watermark_margin; break; default: $x = 0; $y = 0; break; } $dst_x = $x; $dst_y = $y; imagecopymerge($image,$watermark_image,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h,25); if(stristr($image_path_src,".jpg") || stristr($image_path_src,".jpeg")) { header("Content-type: image/jpeg"); imagejpeg($image,NULL,100); } else if(stristr($image_path_src,".png")) { header("Content-type: image/png"); imagepng($image); } else { exit("Sorry, only *.jpg/*jpeg and *.png images supported"); } ImageDestroy($image); } ///////////////////////////////////////////// include(dirname(__FILE__)."/../common.ini.php"); $item = $catalog->items->get("WHERE id=".(int)$_GET["id"]); switch($config["watermark_type"]) { case "text":watermark_text("../rwx/".$item["file"],$config["watermark_text"],$config["watermark_location"],$config["watermark_margin"]);break; case "image":watermark_image("../rwx/".$item["file"],"../rwx/".$config["watermark_image"],$config["watermark_location"],$config["watermark_margin"]);break; } ?>
×
×
  • 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.