Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

image resizer

 
webmaster forum
Activity
0%
 
New Coder
Posts: 26
Topics: 12
January 21, 2009, 05:05:03 AM

you can use this php code for image resize...
name this as imgresize.php

Code:
<?php
$height
50;
$width50;
// Content type
header('Content-type: image/jpeg');
if(!
$filename)
$filename="./images/nopic.jpg";
// Get new dimensions
list($width_orig$height_orig) = getimagesize($filename);

if (
$width && ($width_orig $height_orig)) {
$width = ($height $height_orig) * $width_orig;
} else {
$height = ($width $width_orig) * $height_orig;
}

// Resample
$image_p imagecreatetruecolor($width$height);
$image imagecreatefromjpeg($filename);
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);

// Output
imagejpeg($image_pnull100);
ImageDestroy ($image_p);
?>

$img = xxx; /// change xxx to img name
echo "<img src=\"imgresize.php?filename=$img\" alt=\"$$img\"/>";
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page January 23, 2012, 04:01:15 AM