THUMBNAIL CREATION CLASS
PURPOSE:
This class solves two rather common needs
1 Keeping the uploaded images within a certain reasonable size.
I had many clients who have upload facility where they upload images directly from their camera.
Who needs an image that is 2100 x 1500 pixels in size?
You can use this class to filter all uploads and cut the images to certain size.
2 Creating thumbnails for image/images.
All over the web you can see "click to view larger image".
This class creates those small images quickly and easily.
In short - this class reduces image size and thus file size as well.
ADVANTAGE:
All classes so far made you specify BOTH thumbnail dimensions (width and height).
In a typical situation, though, that is a problem.
In all galleries, CMS-es, shopping carts etc, you don't know both dimensions because various
images will have different proportions.
What you want is to simply keep the image within a certain width OR height.
You don't want to specify BOTH width and height because that would distort
all images that do not have the same proportions.
That is where this class comes in.
Just enter the "higher pixel value" and it will calculate the other value and resize the image proportionally.
I needed such function in several applications. There was no class that does it so I made it.
If you are not sure what "higher pixel value" is have a look:
lesser pixel value
---------
| |
| |
| | higher pixel value
| |
| |
| |
| |
---------
higher pixel value
-------------------------
| |
| |
| | lesser pixel value
| |
-------------------------
TECH DETAILS:
This class relies on GD PHP extension.
You can test if your server has it with a simple PHP script:
<?
phpinfo()
?>
If the GD extesion is present, it will be listed (can be a long scroll though).
When you are specifying the image to be thumbnailed and the name for the image
to be saved as, remember to use a proper file path.
If you are not sure about that, you can use a following script.
<?
if($HTTP_SERVER_VARS){
foreach($HTTP_SERVER_VARS as $Key=>$Value)
{
$$Key = $Value;
print "$$Key -- $Value<br>";
}
}
?>
Values such as
$DOCUMENT_ROOT
$SCRIPT_FILENAME
$PATH_TRANSLATED
will show you what folders/directories your files reside in.
|