DYReImage-PHP
This is the documentation of the DYReImage image resizing project.
It is an image resizing open source project. You can use it to create thumbnails.
You can download the latest release of the project from its GitHub repository.
If you want to clone the project the using the follwing command in the terminal.
$ git clone https://github.com/yusufshakeel/dyreimage-php.git
You can also use bower to install the project. Run the following command to get the project.
$ bower install dyreimage-php
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.
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.
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:
|
$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:
|
$option | array | This holds the options we want to use in order to resize the image. Example
|
Following are the values allowed for the 3 option parameters.
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. |
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 |
This is an integer value. Range: 0 < x <= 100.
In the next tutorial we will learn to resize the sample.jpeg file using DYReImage.
ADVERTISEMENT