PHP code example of joomla-ua / juimage
1. Go to this page and download the library: Download joomla-ua/juimage 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-ua / juimage example snippets
$config['root_path'] = __DIR__;
$config['img_blank'] = 'images/logos';
$juImg = new JUImage\Image($config);
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '77',
'cache' => 'img'
]);
echo '<img src="' . $thumb . '" alt="Apple" width="300" height="100">';
JLoader::register('JUImage', JPATH_LIBRARIES . '/juimage/JUImage.php');
$juImg = new JUImage();
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '77',
'cache' => 'img'
]);
echo '<img src="'. $thumb .'" alt="Apple" width="300">';
$juImg = new JUImage\Image();
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '77',
'cache' => 'img'
]);
echo '<img src="'. $thumb .'" alt="Apple" width="300">';
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '95',
'webp' => true
]);
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '95',
'webp' => true,
'imagemagick' => false
]);
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '95',
'avif' => true
]);
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '95',
'avif' => true,
'webp' => true
]);
$thumb = $juImg->render('https://www.youtube.com/watch?v=xxxxxxxxxxx', [
'w' => '300',
'h' => '100'
]);
$thumb = $juImg->render('https://vimeo.com/xxxxxxxxx', [
'w' => '300',
'h' => '100'
]);
$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300'
]);
// Image size for thumb
$size = $juImg->size($thumb);
echo '<img src="'. $thumb .'" alt="Apple" width="'. $size->width .'" height="'. $size->height .'">';