Friday 14 September 2012

Classes Use in PHP


Class definition:

include('snapshot.class.php');
$myimage = new ImageSnapshot;
$myimage->ImageField = $_FILES['userfile'];
$myimage->Width = 100;
$myimage->Height = 100;
$myimage->Resize = true;
$myimage->ResizeScale = 50;
$myimage->Position = 'center';
$myimage->Compression = 80;

If you want to save the altered image as a file:

if ($myimage->SaveImageAs('temp.jpg')) {
echo '<img src="temp.jpg" border="0" alt="test" />';
} else {
echo $myimage->Err;
}

OR if you want to get the contents of the saved image as a variable:

if ($myimage->ProcessImage() !== false) {
$img = $myimage->GetImageContents();
} else {
echo $myimage->Err;
}


Imagefield

This variable holds the exact array of the $_FILES field that you specify. If the file is not a valid image (jpg, gif, png) the class will return an error when SaveImageAs or ProcessImage is called.

0 comments:

Post a Comment