Getting Started

DYReImage-PHP

Share

This is the documentation of the DYReImage image resizing project.

What is DYReImage?

It is an image resizing open source project. You can use it to create thumbnails.

Download

Latest Release

You can download the latest release of the project from its GitHub repository.

Git Clone

If you want to clone the project the using the follwing command in the terminal.

$ git clone https://github.com/yusufshakeel/dyreimage-php.git

Bower

You can also use bower to install the project. Run the following command to get the project.

$ bower install dyreimage-php

Getting started

After you download the file the project structure will look something like the following.



We are interested in the src/DYReImage directory. This holds the code needed to perform image resize.

Include DYReImage in your project

Lets say we have a project myproject in which we want to use DYReImage.

So, we will include the DYReImage directory which is inside the src directory in our project.

Our project will looking like the following.



We have DYReImage directory and its related files and directories. Then we have an image directory which holds sample.jpeg file.

And we also have an index.php file which is empty at the moment.

Resize Options

In order to resize an image we have to set three variables and pass it to DYReImage.

Variable Type Note
$source string This will hold the complete path of the source image file that we want to resize.
Example:
/myproject/image/sample.jpeg
$destination string This will hold the complete path of the destination image file that we want to generate.
Note! Destination directory path must be valid.
Example:
/myproject/image/output.png
$option array This holds the options we want to use in order to resize the image.
Example
$option = array(
	"height" => 200,
	"width" => "auto",
	"quality" => 80
);

Following are the values allowed for the 3 option parameters.

height

Value Type Note
In Pixel integer Any positive integer value for the height.
Example: 200
In Percentage string If you want resized image to have height X% of original image then use this.
Range: 0 < X% <= 100
Example: "40%"
Predefined string If you want to use predefined values.
Example:
"xs" = 100 //extra small
"sm" = 200 //small
"md" = 400 //medium
"lg" = 800 //large
"xl" = 1600 //extra large
All values in pixels.

width

Value Type Note
In Pixel integer Any positive integer value for the height.
Example: 200
In Percentage string If you want resized image to have height X% of original image then use this.
Range: 0 < X% <= 100
Example: "40%"
Predefined string If you want to use predefined values.
Example:
"auto" //code will compute width proportional to height "xs" = 100 //extra small
"sm" = 200 //small
"md" = 400 //medium
"lg" = 800 //large
"xl" = 1600 //extra large

quality

This is an integer value. Range: 0 < x <= 100.

In the next tutorial we will learn to resize the sample.jpeg file using DYReImage.

Share

Recently Added