Skip to content

php image (local or remote) resizing, compressing and caching script

Notifications You must be signed in to change notification settings

marifuli/phpimageresize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHPImageResize Script

This is a beautiful scrip that will allow you to simply resize, compress and cache your images on the fly. The script is dynamic and flexible and is being updated continuously.

Using The Script

You just need to include a simple function file in your project and you are good to go. So you basically start by including the file in your project.

<?php require_once 'function.resize.php'; ?>

And create folder called cache - with writable permissions (777) and another folder inside cache called remote

Basic Resizing

You need to define the basic settings for your image as an array for the scrip to process:

Resizing by width/height:

<?php
	$settings = array('w'=>300);
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Resizing By Width and Height

<?php
	$settings = array('w'=>300, 'h'=>300);
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Resizing and giving a custom canvas color

<?php
	$settings = array('w'=>300, 'h'=>300, 'canvas-color'=>'#ff0000');
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Resizing by Cropping

<?php
	$settings = array('w'=>300, 'h'=>300, 'crop'=> true);
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Scaling the image

<?php
	$settings = array('w'=>300, 'h'=>300, 'scale'=> true);
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Resizing images from remote location

<?php
	$settings = array('w'=>300, 'h'=>300);
?>
<img src='<?=resize('REMOTE_ADDR',$settings)?>' border='0' />

Compressing Images to JPEG (lossy)

<?php
	$settings = array('w'=>300, 'h'=>300, 'compress'=>true);
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Setting Compression Level (1-99)Low to High

<?php
	$settings = array('w'=>300, 'h'=>300, 'compress'=>true, 'compression'=>70);
?>
<img src='<?=resize($IMG_PATH,$settings)?>' border='0' />

Check Out The Example Here!

Forked By Whizzzkid

Original Source Wes

Cheers!...

About

php image (local or remote) resizing, compressing and caching script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%