1. Go to this page and download the library: Download popphp/pop-image library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
popphp / pop-image example snippets
use Pop\Image\Image;
$img = Image::loadGd('image.jpg');
// Resizes by using the largest dimension as the primary constraint
$img->resize(100)
->setQuality(50)
->writeToFile('image-resized.jpg');
use Pop\Image\Image;
$img = Image::loadGd('image.jpg');
// Resizes by using width as the primary constraint
$img->resizeToWidth(100)
->setQuality(50)
->writeToFile('image-resized-width.jpg');
use Pop\Image\Image;
$img = Image::loadGd('image.jpg');
// Scales the dimensions by the percentage
$img->scale(0.5)
->setQuality(50)
->writeToFile('image-scaled.jpg');
use Pop\Image\Image;
$img = Image::loadGd('image.jpg');
// Crops a section of the image by width and height values
// The X and Y offsets position the crop
$img->crop(120, 80, 100, 200) // $width, $height, $xOffset, $yOffset
->setQuality(50)
->writeToFile('image-cropped.jpg');
use Pop\Image\Image;
$img = Image::loadGd('image.jpg');
// The offset is automatically centered,
// unless otherwise passed as a second parameter
$img->cropThumb(100)
->setQuality(50)
->writeToFile('image-cropped-thumb.jpg');
use Pop\Image\Image;
// Return an instance of the GD adapter
$gdImage = Image::loadGd('path/to/image.jpg');
// Returns an instance of the Imagick adapter
$imagickImage = Image::loadImagick('path/to/image.jpg');
use Pop\Image\Image;
// Return an instance of the GD adapter
$gdImage = Image::loadGdFromString($imageContents, 'image.jpg');
// Returns an instance of the Imagick adapter
$imagickImage = Image::loadImagickFromString($imageContents, 'image.jpg');
use Pop\Image\Image;
// Return an instance of the GD adapter
$gdImage = Image::createGd(640, 480, 'image.jpg');
// Returns an instance of the Imagick adapter
$imagickImage = Image::createImagick(640, 480, 'image.jpg');
use Pop\Image\Image;
// Return an instance of the GD adapter
$gdImage = Image::createGdIndex(640, 480, 'image.gif');
// Returns an instance of the Imagick adapter
$imagickImage = Image::createImagickIndex(640, 480, 'image.gif');
use Pop\Image\Image;
// Return an instance of the GD adapter
$gdImage = Image::loadGd('path/to/image.jpg');
// Return an instance of the GD adapter
$gdImage = Image::loadGdFromString($imageContents, 'image.jpg');
// Return an instance of the GD adapter
$gdImage = Image::createGd(640, 480, 'image.jpg');
// Return an instance of the GD adapter
$gdImage = Image::createGdIndex(640, 480, 'image.jpg');
use Pop\Image\Image;
// Returns an instance of the Imagick adapter
$imagickImage = Image::loadImagick('path/to/image.jpg');
// Returns an instance of the Imagick adapter
$imagickImage = Image::loadImagickFromString($imageContents, 'image.jpg');
// Returns an instance of the Imagick adapter
$imagickImage = Image::createImagick(640, 480, 'image.jpg');
// Returns an instance of the Imagick adapter
$imagickImage = Image::createImagickIndex(640, 480, 'image.jpg');