11th Jun 2006

PHP Class: Image Snapshot 1.3

Inspired by Backpackit.com’s image management, Image Snapshot can take a portion of an image (crop) to specific dimensions, from different areas of the original image.

This class has been created for the purpose of manipulating an uploaded image, and creating a Thumbnail image that does not alter the aspect ratio, and yet represents the contents of the original image. I’m sure other uses can be found for the Image Snapshot class, but I’ll leave that to you. I use it for Photo Galleries, and Shopping Cart systems.

View the manual to get a clearer picture.

This class supports:

  • Jpg, Gif, Png files
  • Output to Jpg
  • Can resize images before applying the crop
  • Can crop from any part of the image

Sites using this class:

Change Log
05-12-2005 1.3 Release
05-12-2005 Added: ImageFile field, can now load image from saved file.
05-12-2005 Added: custom position type, specify by percentages. Read updated manual for help with this.
28-11-2005 1.2 Release
28-11-2005 Added: ReturnedWidth and ReturnedHeight variables, for more feedback.
28-11-2005 Fixed: if crop area was bigger than original image, mixed results ocurred.
28-11-2005 1.1 Release
28-11-2005 Added: support for Image input with a variable
27-11-2005 1.0 Release

Downloads

Technorati: php, images, gd

10 Responses to “PHP Class: Image Snapshot 1.3”

  1. Rui Cruz Says:

    Hi, I’d like to say that I love this class and I use it all the time, there’s just one thing missing.

    You should add the option to resize by pixels instead of just by percentage.

  2. David Says:

    Hello! Just wanted to tell you that the “Download Manual (highly reccomended) (Pdf file)” doesn’t work :(

  3. jc Says:

    Right you are, David. I’ve just been transfered to a new server, and it wasn’t just this file that had ‘gone missing’. Everything is peachy now tho, and thanks for pointing it out :) Let me know how you go

  4. Brad Says:

    Great image tool and cool pic in pdf manual. I need to dynamicly move the crop box around in real time. Any way you can think that could be done with this class? The user would have to be able to see the orginal image with the box overlay like in the pdf manual. Any advise would be great.

  5. jc Says:

    I too would like to achieve that. I think the only way to make it happen would be to use Javscript or Flash in conjunction with the class. Would be very neat though!

  6. Luke Says:

    hello sir
    Thanks for your work - very interesting.
    I have been tinkering with your script “IMAGE SNAPSHOT CLASS” as i have been trying allsorts in the hope of achieving the following:
    To silently submit the size of an image (as displayed in the users browser) to retrieve its width in pixels. For example if a 1px x 1px red gif image is set to 100% width for display in a browser, to transmit back the final viewing width to php for further processing. The users allowable window width may be something like 602px max and so the Gif would be stretched to 602px ?? How can that info be received to be processed further and without the use of javascript. I was hoping your snapshot script would take an image as displayed on-screen. I am not interested at all in the displaying of the final image as it is for retrieving a measurement only to apply to further processing.
    Hope you can help with this. Thanks again for your work - just taking a good look at your sliding boxes.

  7. jc Says:

    Ok, I’m having trouble understanding the question. Do you want the dimensions of the image Before the class manipulates it, or After?

  8. Luke Says:

    I am trying to get users avavilable screen width without javascript but I realize now that this is not going to be possible without javascript.

  9. Phil McDonald Says:

    Hi.

    Love the class. I’m trying to integrate it into the MG2 photo gallery. I can get it to create a thumbnail, no problem, but MG2 supports multiple uploads and when I try to upload 2 or more images at the same time, I get an error:

    Fatal error: Cannot redeclare class imagesnapshot in /usr/local/psa/home/vhosts/digitalexpression.ca/httpdocs/clients/funskate/gallery3/includes/snapshot.class.php on line 86

    Can you point out how to get around this? Any help would be very appreciated.

  10. Phil McDonald Says:

    Never mind. Easy answer if I’d been thinking. Change my include to require_once.

    Thanks

Leave a Reply