simpleAdminPlus v1.0

simpleAdminPlus Image

Click on a function to expand it.

load() $simpleAdmin->image->load()
load() – Opens an image so you can resize, convert, and save it.

Usage

$simpleAdmin->image->load( [filename] )
filename string (required)
The filename and path to the image.
../images/image.jpg Or if your uploading an image $_FILES['photo']['tmp_name']

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

// Resize by width to maintain aspect ratio
$simpleAdmin->image->resize_to_width(150);

 // Save as a .gif image
$simpleAdmin->image->save('../thumbs/image_thumb.gif');

?>
resize() $simpleAdmin->image->resize()
resize() – Resize an image to a new width and height.

Usage

$simpleAdmin->image->resize( [width], [height] )
width int (required)
New width of the image.
height int (required)
New height of the image.

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

// Resize by width to maintain aspect ratio
$simpleAdmin->image->resize(150, 75);

 // Save as a .gif image
$simpleAdmin->image->save('../thumbs/image_thumb.gif');

?>
resize_to_width() $simpleAdmin->image->resize_to_width()
resize_to_width() – Resize an image by its width while maintaining its aspect ratio.

Usage

$simpleAdmin->image->resize_to_width( [width] )
width int (required)
New width of the image.

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

// Resize by width to maintain aspect ratio
$simpleAdmin->image->resize_to_width(150);

 // Save as a .gif image
$simpleAdmin->image->save('../thumbs/image_thumb.gif');

?>
resize_to_height() $simpleAdmin->image->resize_to_height()
resize_to_height() – Resize an image by its height while maintaining its aspect ratio.

Usage

$simpleAdmin->image->resize_to_width( [height] )
height int (required)
New height of the image.

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

// Resize by width to maintain aspect ratio
$simpleAdmin->image->resize_to_height(75);

 // Save as a .gif image
$simpleAdmin->image->save('../thumbs/image_thumb.gif');

?>
scale() $simpleAdmin->image->scale()
scale() – Scale an image by a percentage.

Usage

$simpleAdmin->image->scale( [percent] )
percent int (required)
The percentage to resize the image by.

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

// Resize by width to maintain aspect ratio
$simpleAdmin->image->scale(50);

 // Save as a .gif image
$simpleAdmin->image->save('../thumbs/image_thumb.gif');

?>
save() $simpleAdmin->image->save()
save() – This function allows you to save your image, and convert your image to a jpg, png, or gif.

Usage

$simpleAdmin->image->save( [filename], [compression], [permissions] )
filename string (required)
The filename of the image including the image path to where you want to save it. The format of the image is set by the extension.
compression int (default=100)
For jpeg images only. Sets the compression level of the image. 100 is the highest zero is the lowest.
permissions int (default=Not Set)
Set read/write permissions to the file.

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

 // Save as a .gif image
$simpleAdmin->image->save('../thumbs/image_thumb.gif');
?>
output() $simpleAdmin->image->output()
output() – This will output the image in the browser, and set the content-type to the correct format

Usage

$simpleAdmin->image->output( [type] )
type string (required)
The type of image you want to output. ('jpg', 'gif', 'png')

Example

<?php
$simpleAdmin->image->load('../images/image.jpg');

 // Output as a .png
$simpleAdmin->image->output('png');
?>