This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

Create thumbnail using php and gd library

The following PHP code will create thumbnail images on the fly and since it uses the PHP GD2 library, you will need an installation of PHP with at least GD 2.0.1 enabled.. This is a very simple script and very easy to customise.

<?php
header 
(“Content-type: image/jpeg”);
$image $_GET['thumimg'];

if(!isset($w) && !isset($h)){
 
$w 110//default width if $w is not set
 
$h 135//default height if $h is not set
}

$x = @getimagesize($image);// get image size
$sw $x[0];// width
$sh $x[1];// height
$im = @ImageCreateFromJPEG ($image) or // Read JPEG Image
$im false// If image is not JPEG


if (!$im)
 
readfile($image);// return the actual message if error occurs.
else {
// Create the resized image destination
   
$thumb = @ImageCreateTrueColor ($w$h);
// Copy from image source, resize it, and paste to image destination
   
@ImageCopyResampled ($thumb$im0000$w$h$sw$sh);
// Output resized image
   
@ImageJPEG ($thumb);
}
?>

save the above code as thumbimg.php.

How to use:
<–without specifying the width and height–>
<img src=”http://www.mysite.com/thumbimg.php?thumimg=example.jpg” />

<–with height and width–>
<img src=”http://www.mysitee.com/thumbimg.php?thumimg=example.jpg&w=100&h=100″ />

VN:F [1.5.7_846]
Rating: 7.5/10 (2 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)

Related posts:

  1. Water mark images using PHP 5 and GD Library
  2. Simple php watermark script
  3. BitDefender Antivirus
  4. How to create random passwords using php

Leave a Reply

Comments (required)

Spam Protected