1. Go to this page and download the library: Download joomla/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/ */
joomla / image example snippets
use Joomla\Image\Image;
// Creating a new Image object, passing it an existing handle.
$resource = imagecreate(100, 100);
$image = new Image($resource);
// Creating a new Image object, passing it an image path
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
// Creating a new Image object then manually calling `loadFile`
$image = new Image;
$image->loadFile(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
use Joomla\Image\Image;
$image = new Image();
$image->loadFile(JPATH_ROOT . '/path/to/image.png')
->crop(600, 250)
->toFile(JPATH_ROOT . '/tmp/image.png');
use Joomla\Image\Image;
// Create our image object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
// Resize the image using the SCALE_INSIDE method
$image_resized = $image->resize(300, 150, true, Image::SCALE_INSIDE);
// Write it to disk
$image_resized->toFile(JPATH_ROOT . '/tmp/bar_resized.png');
use Joomla\Image\Image;
// Create our image object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
// Crop the image to 150px square, starting 10 pixels from the left, and 20 pixels from the top
$image_resized = $image->crop(150, null, 10, 20);
// Write it to disk
$image_resized->toFile(JPATH_ROOT . '/tmp/bar_cropped.png');
use Joomla\Image\Image;
// Set the desired sizes for our thumbnails.
$sizes = array('300x300', '64x64', '250x125');
// Create our object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/uploadedImage.jpg');
// Create the thumbnails
$image->createThumbs($sizes, Image::SCALE_INSIDE);
use Joomla\Image\Image;
// Create our object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
// Write to disk
$image->toFile(JPATH_ROOT . '/tmp/bar.jpg', IMAGETYPE_JPEG, array('options' => 65));
use Joomla\Image\Image;
// Create our object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
// Enable output buffering
ob_start();
// Retrieve data blob
$image->toFile(null, IMAGETYPE_PNG);
$imageBlob = ob_get_clean();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.