Been awhile since I've posted something useful. I hope this is. This is a rebuild of my ThumbIt script, and my resizing snipper here.
Mr. Thumb is finally ported to OOP for easy use. Maybe someone will come across it here, and if so, I hope it's helpful!
Mr. Thumb does not cache it's images, I'm hoping to add it soon if I come back to this.
However it does support transparency for both PNG images and GIF images.
mrthumb.class.php
PHP Code:
<?php
/*************************************** * Mr. Thumb * Version 1.0 ( Build 1 ) * By Jordan Thompson (WASasquatch) ****************************************/
class MrThumb {
// This is your array of supported image formats. // Exclude types you don't want rendered. var $valid_ext = array( 'png', 'jpg', 'jpeg', 'gif', 'bmp', 'wbmp' );
// Whether or not that script should continue var $halt = false;
// Image Configuration array and Source Image var $image = array(); var $s_image;
// Mr. Thumb Version var $name = 'Mr. Thumb'; var $version = '1.0'; var $build = 1; var $developer = 'Jordan Thompson'; var $contact = 'jordanslost at gmail';
// The image you are resizing. Can be a local path as well. $image = 'http://jordan.rave5.com/imgarch/clock.gif';
// In this example we are resizing the image in proportionate sizes. // Below we are specifying the MAX width and height. $maxwidth = 100; // Pixels $maxheight = 130; // Pixels
// Start Mr. Thumb v1.0 $mrthumb = new MrThumb();
// Render the image $mrthumb->render( $image );
// Resize the image proportionately $mrthumb->proportion( $maxwidth, $maxheight );
// Finally, output the image to the browser! $mrthumb->output();
// Clean up after you are done!;) $mrthumb->clear_cache();
?>
Constrained Example (example.php)
PHP Code:
<?php
include './mrthumb.class.php';
// The image you are resizing. Can be a local path as well. $image = 'http://jordan.rave5.com/imgarch/clock.gif';
// In this example we are resizing the image in proportionate sizes. // Below we are specifying the MAX width and height. $width = 100; // Pixels $height = 100; // Pixels
// Start Mr. Thumb v1.0 $mrthumb = new MrThumb();
// Render the image $mrthumb->render( $image );
// Resize the image and constrain it's width and height $mrthumb->constrain( $width, $height );
// Finally, output the image to the browser! $mrthumb->output();
// Clean up after you are done!;) $mrthumb->clear_cache();
?>
There is also a save function, if you want to just save the new thumbnail to a folder, where you would have another script load it.
PHP Code:
<?php
include './mrthumb.class.php';
// The image you are resizing. Can be a local path as well. $image = 'http://jordan.rave5.com/imgarch/clock.gif';
// Save to destination. Use a trailiing slash. $destination = 'home/user/public_html/cache_images/';
// Name of the cached file. $filename = 'cache_clock';
// Quality of the image $quality = 100; // percent
// In this example we are resizing the image in proportionate sizes. // Below we are specifying the MAX width and height. $maxwidth = 100; // Pixels $maxheight = 130; // Pixels
// Start Mr. Thumb v1.0 $mrthumb = new MrThumb();
// Render the image $mrthumb->render( $image );
// Resize the image proportionately $mrthumb->proportion( $width, $height );
// Save the file to a specified directory, with a specified name. $mrthumb->saveto( $destination, $filename, $quality );
// Clean up after you are done!;) $mrthumb->clear_cache();