1. Go to this page and download the library: Download ryantxr/php-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/ */
ryantxr / php-image example snippets
try {
// Create a new Image object
$image = new \Ryantxr\Image();
// Magic! ✨
$image
->load('image.jpg') // load image.jpg
->autoOrient() // adjust orientation based on exif data
->resize(320, 200) // resize to 320x200 pixels
->flip('x') // flip horizontally
->colorize('DarkBlue') // tint dark blue
->border('black', 10) // add a 10 pixel black border
->overlay('watermark.png', 'bottom right') // add a watermark image
->toFile('new-image.png', 'image/png') // convert to PNG and save a copy to new-image.png
->toScreen(); // output to the screen
// And much more! 💪
} catch(Exception $err) {
// Handle errors
echo $err->getMessage();
}
// make an empty object
$object = new \Ryantxr\Image;
// make a blank image of with certain dimensions
$object = new \Ryantxr\Image(600, 400); // width=600, height=600
$string = file_get_contents('image.jpg');
$obj = new \Ryantxr\Image;
$obj->fromString($string);