Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board ImageFill Transparent Image Download Source Code
Author Details Code Information
Relish ( Mike )

Pinned 3 Codes
Posted 1 Coding Articles

Send A Message
View Coders Profile
Language PHP (Hypertext Preprocessor)
Expires Never
Length 1,326 Characters (51 Lines)
Password no password
  1. $width = $_GET['width'];
  2.        $height= $_GET['height'];
  3.        $filename = $_GET['file'];
  4.        $ext = strtolower( substr($filename, -3) );
  5.  
  6.        if ($ext == "jpg") {
  7.               header('Content-type: image/jpeg');
  8.        } else if ($ext == "png") {
  9.               header('Content-type: image/png');
  10.        } else if ($ext == "gif") {
  11.               header('Content-type: image/gif');
  12.        }
  13.  
  14.        list($width_orig, $height_orig) = getimagesize($filename);
  15.  
  16.        $ratio_orig = $width_orig / $height_orig;
  17.  
  18.        if ($width_orig < $varwidth) {
  19.               $width = $width_orig;
  20.               $height = $height_orig;
  21.        } else {
  22.               if ($width / $height > $ratio_orig) {
  23.                 $width = $height * $ratio_orig;
  24.               } else {
  25.                 $height = $width / $ratio_orig;
  26.               }
  27.        }
  28.  
  29.        $image_p = imagecreatetruecolor($width, $height);
  30.  
  31.        $white = imagecolorallocate($image_p, 255, 255, 255);
  32.        imagefill($image_p, 0, 0, $white);
  33.  
  34.        if ($ext == "jpg") {
  35.               $image = imagecreatefromjpeg($filename);
  36.        } else if ($ext == "png") {
  37.               $image = imagecreatefrompng($filename);
  38.        } else if ($ext == "gif") {
  39.               $image = imagecreatefromgif($filename);
  40.        }
  41.  
  42.        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
  43.  
  44.  
  45.        if ($ext == "jpg") {
  46.               imagejpeg($image_p, NULL, 100);
  47.        } else if ($ext == "png") {
  48.               imagepng($image_p);
  49.        } else if ($ext == "gif") {
  50.               imagegif($image_p, NULL, 100);
  51.        }
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
Page 1 of 1
 
 
Latest News About Coder Profile
Coder Profile Poll
Why do you get bored with programming?

Not enough time to do something productive
I run out of ideas
Too hard to show people my creations
Everything i do has too many errors, and it's too hard
I don't get bored!!!


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
1.67 Year Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2010, Scott Thompson, All Rights Reserved