WorldWideScripts.net Delivering the best Add-Ons in more than 37 languages.

中文(简体), English, हिन्दी/हिंदी, Español/Castellano, العربية, Русский язык, Français, 中文 (台灣), বাংলা, Bahasa Indonesia, اردو, Português, Deutsch, Bahasa Melayu (بهاس ملايو‎), 日本語 (にほんご), فارسی, Italiano, తెలుగు, Türkçe, ગુજરાતી, Język polski/polszczyzna, Tiếng Việt, ಕನ್ನಡ, Українська мова, ไทย
PHP Scripts / Images and Media

anySize - Caching image resizer

— Add-On to WorldWideScripts.net

Subscribe to our feed to stay up to date!

New! Follow us as you want it!


anySize - Caching image resizer - CodeCanyon Item for Sale

Ads

Ad: Bluehost hosting

Description

anySize is a lightweight, drop-in, fully automated, caching, make-you-coffee-and-serve-it-in-bed script that lets you request and generate images (jpg, gif or png) of any size.

For example:

You upload “image.png” to your image folder, “images”
  1. <img src=”images/image.png” />
    The image is returned at its native resolution
  2. <img src=”images/resized/image.png?s=thumb” />
    A thumbnail is presented
  3. <img src=”images/resized/image.png?s=medium” />
    A medium sized image is presented
  4. <img src=”images/resized/image.png?w=100&h=150” />
    An image with max width 150px and max height 100px is presented. Aspect ratio is maintained.
  5. <img src=”images/resized/image.png?w=100&h=150&a=false” />
    An image with width 150px and height 100px is presented. Aspect ratio is NOT maintained.

And now for the awesome:

When you request an image the first time the result is stored in a cache folder and all further requests use that cache. Image file updated and re-uploaded? No need to flush the cache; everything is automatically taken care of!
Want to define the size of your “thumbnail” image? Want to add a “megaawesome” option so you can request images/image.png?s=megaawesome? Want to disable arbitrary resizing (options 4 & 5)? No problem! Everything is set up in the first few lines of the code using intuitively-named variables. Works out of the box but is extremely easy to customize.

The following are flags and variables the system understands:

s: (Set Size)
Ex: <img src=”images/resized/image.png?s=someSize” />
Returns an image of a pre-determined size (as set at the top of the anySize.php file)
The default sizes out of the box are:

  • s=thumb: max size 60×60 image.
  • s=small: max size 200×200 image.
  • s=medium: max size 400×400 image.
  • s=large: max size 800×800 image.

Note: These sizes are truly simple to change, add, remove, etc. Comments in the file show how to edit these sizes.

w: (Width)
Ex: <img src=”images/resized/image.png?w=100” />
Returns an image with a width of 100px. Unless specified, aspect ratio is preserved.

h: (Height)
Ex: <img src=”images/resized/image.png?h=150” />
Returns an image with a height of 100px. Unless specified, aspect ratio is preserved.

a: (Aspect Ratio)
Ex: <img src=”images/resized/image.png?w=100&h=150&a=false” />
Returns an image with a width of 100px and a height of 150px; Aspect ratio is ignored and the image WILL be 100px wide and 150px tall if a=false

Note: If you set both w and h and do not set a to “false” the system will produce an image that fits within the box defined by w and h while maintaining the aspect ratio. Essentially w and h, when set together, form a bounding box for the result image. See Example 4 for how this might look in code.

But wait! There’s more!

Included in the anySize download is a speed-optimized version of the script that uses just the size flag (s) and boosts the cache speed for truly lightweight and lightening fast operation.

Updates!

  • August 7th 2009: Added transparency support for PNG and GIF files.


Download
Other components in this categoryAll components of this author
CommentsFrequently asked questions and answers

Properties

Created:
7 August 09

Last Update:
N/A

Compatible Browsers:
IE6, IE7, IE8, IE9, IE10, Firefox, Safari, Opera, Chrome

Software Version:
PHP 5.x

High Resolution:
No

Files Included:
PHP

Keywords

eCommerce, All Items, cache, gallery, image, images, resize, resizing, reziser, thumbnail generation, thumbnails