GithubHelp home page GithubHelp logo

imagick-image-processor's Introduction

Imagick Image Processor

This library, created with focuses on simple methods for image processing using the Imagick PHP extension.

Requirements

  • PHP extension ext-imagick version > 3.7

Installation

To install Imagick Image Processor using Composer, run the following command:

composer require kenura/imagick

Methods

Resize

The resizeImage method resizes an image with the specified width and height.

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

Compress

The compressToJpg method compresses an image to JPEG format with a specified quality.

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

Watermark

The addWatermark method adds a watermark to an image with various positioning options, preserving the width*height ratio of the watermark.

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

Opacity

The addOpacity method makes an image transparent with a specified opacity percentage and saves it as PNG.

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

Resize-Compress

The resizeAndCompress method combines image resizing and compression.

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

Resize-Watermark-Compression

The resizeWatermarkAndCompress method combines image resizing, watermarking, and compression.

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

Usage

use YourNamespace\ImageProcessor;

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

// Use the methods based on your requirements
$imageProcessor->resizeImage($inputImagePath, $outputImagePath, $width, $height);
$imageProcessor->compressToJpg($inputImagePath, $outputImagePath, $quality);
$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);

Acknowledgment

Thanks to @[email protected] for using this library!

Feel free to contribute or report issues.

imagick-image-processor's People

Contributors

kenura-r-gunarathna avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.