Skip to content

PHP Imager is a simple script that makes image management easier: crop, cache and customize.

Notifications You must be signed in to change notification settings

Jany-M/php-imager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Imager

PHP Imager makes image management easier when it comes to manipulating, caching and customizing images. It has a WordPress twin, WP-Imager

Uses TimThumb for image resizing and caching

Caches images in a custom folder, to avoid clutter

Requirements

  • PHP 5.2.x or higher
  • GD image library

Get started

  1. Place the provided cache_img folder in your site's root folder.

Make sure that cache_img/cache is writable, in case images are not displaying.

  1. Include php-imager.php where you need it.
<?php include 'php-imager.php'; ?>

If you want to have pretty img urls, then there's an extra step:

  • If you don't have an .htaccess yet, place the one provided in your site's root folder.
  • If you already have an .htaccess, then adapt it, following the one provided.

If you don't complete every step the script won't work.

Parameters

<?php
php_imager($width=null, $height=null, $imgurl=null, $nohtml=false, $class=null, $crop=null, $bg_color=null);
?>
Parameter Type Description & Options Default
width int Resize dimension of width (dont put 'px' after size) 100
height int Resize dimension of height (dont put 'px' after size) 100
crop int Type of cropping to perform 0 = Resize to Fit exactly specified dimensions (no cropping) 1 = Crop and resize to best fit the dimensions (default) 2 = Resize proportionally to fit entire image into specified dimensions, and add borders if required 3 = Resize proportionally adjusting size of scaled image so there are no borders gaps 1
class string class name/names to append to image. Separate with space. NULL
imgurl string URL of the image (eg. http://www.mysite.com/image.jpg). NULL
nohtml bool When false, image is wrapped in its img HTML tag. If true, only the image url is returned. false
bg_color int When using crop value '2' (with borders) you can customize the borders color (the canvas beneath the image). ffffff

Defaults

  • Function always returns to avoid yet another parameter, so simply echo it in your code.
  • Processed IMG's quality is always 100
  • Caching is done in a cache_img folder, in the root of your website (provided)
  • Pretty img urls are enabled by default. Adapt the .htaccess provided with the script.

Usage

Please refer to its WP twin, WP-Imager

Conflicting Params

Clearly there are some parameters you cannot use together.

  • $class won't do anything if $nohtml = true

Changelog

5/11/2015

Credits

TimThumbs (discontinued): BinaryMoon

Author

Jany Martelli @ Shambix

License

Released under the GPL v3 License

About

PHP Imager is a simple script that makes image management easier: crop, cache and customize.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published