Create Image's Thumbnail on-the-fly

Nov 4, 2008 | Tags: PHP, Image | del.icio.us del.icio.us | digg Digg

Use this class to display your images with scale. Its very useful to create your images' thumbnail in your image gallery or shopping cart applications. You use this class by put it directly in your <img> tag like this:

Listing 1: listing-1.html

  1. <!-- display product1.jpg in original size -->
  2. <img src="image.php?filename=product1.jpg">
  3.  
  4. <!-- display product2.jpg scaled by 0.4 -->
  5. <img src="image.php?filename=product2.jpg&scale=0.4">
  6.  
  7. <!-- try to display missing.jpg,
  8.      if it doesn't exist, display default image -->
  9. <img src="image.php?filename=missing.jpg">

Requirements:

  • PHP with GD support enabled.

Features:

  • Display image in any scale
  • Support JPEG, GIF and PNG images
  • Display default image if requested image doesn't exist.

Related Articles

The Downloads

Leave a comment

Name (required)
Email (will not be published) (required)
Website

Characters left = 1000