With this class you will be able to:

  • Manipulate any jpg, gif, or png image
  • Convert it to the desired image type
  • Resize the image to any width or height
    • While maintaining the original proportions
  • Extract a square portion of the image
  • Resize the image unlimited times without losing the original image's quality
  • Save the image(s) to your server
  • Display the image to your user

Creates a new image object.

Example
$image = new Image;

Opens an image resource from specified $website. This image will be used in all of the methods that follow, and so must be called first.

$website The url of the image you would like to work with.
Returns True if successful, false if not.
Example
$image->url ('http://www.somesite.com/images/copy.jpg');

This is so that you can know what you are working with.

Returns Either '.jpg', '.gif', or '.png'.
Example
$type = $image->type();

If the image is a gif and you would like to covert it to a jpg for instance, you can do that here.

$type Either 'jpg', 'gif', or 'png'.
Returns True if successful, false if not.
Example
$image->convert ('jpg');

This will resize the original image within the width and height specified while still maintaining its original proportions. You can call this method as many times as you like, and you will always be working with the original image.

$width The maximum width (in pixels) you would like this image to be.
$height The maximum height (in pixels) you would like this image to be. This value defaults to 80% of whatever width is specified.
Returns True if successful, false if not.
Example
$image->resize (500); // Takes the users massive 10 Megapixel image, and cuts it down to size for the web.

This method will generate a square image of $pixels size.

$pixels The size (in pixels) you would like the square to be.
Returns True if successful, false if not.
Example
$image->square (80);

This will save an image to the location on your server.

$location Where you would like the image to reside on your server. Be sure to include the full directory path.
$quality The quality of the image created from 0 (worst quality, smallest file size) to 100 (best quality, biggest file size). Default is 80.
Returns True if successful, false if not.
Example
$image->save ('/base/directory/mysite.com/images/copied.jpg');

This method outputs the image directly to the browser.

$quality The quality of the image created from 0 (worst quality, smallest file size) to 100 (best quality, biggest file size). Default is 80.
Returns True if successful, false if not.
Example
$image->display (80);
Download