WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Quick PHP GD JPG Thumbnailer Script
Categories : PHP, GD image library, Graphics Click here to Update Your Picture
Jon Ellis-Jones
Date : Oct 28th 2004
Grade : 3 of 5 (graded 7 times)
Viewed : 6041
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Jon Ellis-Jones
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php

// quick thumbnailer
// pretty self explanatory, uses PHP GD to thumbnail photographs in the directory marked by $config['path'];
// just a three minute script thats good for people looking for an easy quick thumbnailer.
// ~dovka

$config = array();
$config['path'] = "./";
$config['t_width'] = 120;
$config['t_height'] = 98;
$config['ignore'] = array("",".","..");
$config['prefix'] = "thumb_";

// don't edit below this line
// start with defining variables

$done = 0;
define("IMAGE_JPG", 2);
define("ENDL", "\n");

if(
$handle = opendir($config['path'])) {
    while(
false !== ($file = readdir($handle))) {
        if(!
array_search($file,$config['ignore'])) {
           
// check for JPG
           
list($im_width, $im_height, $type) = getimagesize($file);
            if(
$type != IMAGE_JPG) {
                continue;
            }
           
           
$op .= "found -> <a href='{$file}'>$file</a>" . ENDL;
           
$im = @imagecreatefromjpeg($file);
            if(!
$im) {
               
$op .= "fail  -> couldn't create sour image pointer." . ENDL;   
                continue;
            }
           
            if(
file_exists($config['prefix'] . $file) || substr($file, 0, strlen($config['prefix'])) == $config['prefix']) {
               
$op .= "note  -> this file has already got a thumbnail." . ENDL;   
                continue;
            }

           
$to = imagecreatetruecolor($config['t_width'],$config['t_height']);
            if(!
$to) {
               
$op .= "fail  -> couldn't create dest image pointer." . ENDL;   
                continue;
            }           
           
            if(!
imagecopyresampled($to, $im, 0, 0, 0, 0, $config['t_width'], $config['t_height'], $im_width, $im_height)) {
               
$op .= "fail  -> couldn't create thumbnail. php fail." . ENDL;   
                continue;
            }
           
           
// save file
           
imagejpeg($to, $config['prefix'] . $file);
           
$op .= "done  -> created thumb: <a href='{$config['prefix']}{$file}'>{$config['prefix']}{$file}</a>" . ENDL;   
           
$done++;
        }
    }
}
closedir($handle);
$op .= "fin   -> {$done} file(s) written" . ENDL;

echo
"<pre>";
echo
$op;
echo
"</pre>";

exit;

?>



crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, GD image library, Graphics
Create a Thumbnail Using PHP, GD and Exif
Categories : PHP, Graphics, Exif, GD image library
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
Simple PHP Bar Graph using GD library
Categories : PHP, GD image library, Graphics, Arrays
Line graphics generation library written in PHP + GD library (spanish comments)
Categories : PHP, Graphics, GD image library
A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP, Security, Graphics, GD image library
EasyPhpThumbnail Class - The EasyPhpThumbnail class allows you to generate thumbnails and handle image manipulation for GIF, JPG and PNG on-the-fly.
Categories : PHP, PHP Classes, Object Oriented, Graphics, GD image library
PHP Image Compression using GD library
Categories : PHP, Compression, GD image library, Graphics
Image Generation Class ( PNG Format )
Categories : PHP, GD image library, PHP Classes, Graphics
a simple pie-chart in php3 (with gd)
Categories : PHP, Graphics, GD image library, Charts and Graphs
Display a bar chart based on random values.
Categories : Graphics, PHP, GD image library, Charts and Graphs
CAPTCHA[Image verification]
Categories : PHP, Security, GD image library, Graphics, Sessions
imageMarker v 3.00 with new advanced features
Categories : PHP, PHP Classes, Graphics, GD image library