PHP code example of kenura / imagick

1. Go to this page and download the library: Download kenura/imagick 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/ */

    

kenura / imagick example snippets


public function resizeImage($inputImagePath, $outputImagePath, $width, $height);

public function compressToJpg($inputImagePath, $outputImagePath, $quality = 80);

public function addWatermark($inputImagePath, $outputImagePath, $watermarkImagePath, $position = 'center', $widthPercent = 10, $heightPercent = 10);

public function addOpacity($inputImagePath, $outputImagePath, $opacityPercent);

public function resizeAndCompress($inputImagePath, $outputImagePath, $width, $height, $quality = 80);

public function resizeWatermarkAndCompress($inputImagePath, $outputImagePath, $width, $height, $watermarkImagePath, $position = 'center', $widthPercent = 10, $heightPercent = 10, $quality = 80);

use YourNamespace\ImageProcessor;

// Create an instance of the ImageProcessor
$imageProcessor = new ImageProcessor();

// Use the methods based on your lity);
$imageProcessor->addWatermark($inputImagePath, $outputImagePath, $watermarkImagePath, $position, $widthPercent, $heightPercent);
$imageProcessor->addOpacity($inputImagePath, $outputImagePath, $opacityPercent);
$imageProcessor->resizeAndCompress($inputImagePath, $outputImagePath, $width, $height, $quality);
$imageProcessor->resizeWatermarkAndCompress($inputImagePath, $outputImagePath, $width, $height, $watermarkImagePath, $position, $widthPercent, $heightPercent, $quality);