1. Go to this page and download the library: Download thapp/jitimage 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/ */
// convert png to jpg:
'/images/<params>/<source>/filter:conf;f=jpg'
// convert png to jpg:
JitImage::source($filePNG)->toJpeg()->get();
JitImage::source($fileJPP)->toPng()->scale(50);
// get the original image:
JitImage::source('path/to/myimage.jpg')->get();
// proportionally resize the image have a width of 200px:
JitImage::source('path/to/myimage.jpg')->resize(200, 0);
// resize the image have a width and height of 200px (ignores aspect ratio):
JitImage::source('path/to/myimage.jpg')->resize(200, 200);
// crop 500px * 500px of the image from the center, creates a frame if image is smaller.
JitImage::source('path/to/myimage.jpg')->crop(500, 500, 5);
// You may also specify a background color for the frame:
JitImage::source('path/to/myimage.jpg')->crop(500, 500, 5, 'fff');
// crop 500px * 500px of the image from the center, resize image if image is smaller:
JitImage::source('path/to/myimage.jpg')->cropAndResize(500, 500, 5);
// resize the image to best fit within the given sizes:
JitImage::source('path/to/myimage.jpg')->fit(200, 200);
// crop 200px * 200px of the image from the center, resize image if image is smaller and apply a greyscale filter:
JitImage::source('path/to/myimage.jpg')->filter('gs')->cropAndResize(200, 200, 5);
// Percentual scale the image:
JitImage::source('path/to/myimage.jpg')->scale(50);
// Limit the image to max. 200000px:
JitImage::source('path/to/myimage.jpg')->pixel(200000);
// Convert png to jpg:
JitImage::source('path/to/myimage.png')->toJpeg()->get();