This library uses GD and EXIF (optional) PHP extensions so make sure you have them installed.

Overview

imgman

This library uses GD and EXIF (optional) PHP extensions so make sure you have them installed.

It also uses the latest PHP 8.1 features and backwards compatibility isn't yet supported.

Install:

composer require leongrdic/imgman
use Le\ImgMan\{ImgMan, ImageFormat};

Supported formats

Input

  • any image format supported by php-gd

Input methods: fromDataUrl(), fromString(), fromFile()

Output

Call the output() method with the wanted output format:

  • ImageFormat::jpeg
  • ImageFormat::png
  • ImageFormat::webp (make sure your php-gd is configured to work with webp)

After that use: toDataUrl(), toString(), toFile()

Example usages

$rawImageBytes = new ImgMan()
    ->fromDataUrl($dataUrlFromJS)
    ->cacheExif()
    ->downscale(2048)
    ->rotateFromExif() // rotating after downscaling should use less memory and be a bit faster
    ->output(ImageFormat::jpeg, quality: 75)
    ->toString();
new ImgMan()
    ->fromFile('example.png')
    ->downscale(1920, 1080)
    ->output(ImageFormat::png)
    ->toFile(); // use input filename (replace original file)
$dataUrl = new ImgMan()
    ->fromString($rawImageBytes)
    ->output(ImageFormat::webp, quality: 80)
    ->toDataUrl();

Notice

This library hasn't yet been fully tested and is to be used at your own responsibility. Any feedback and improvement suggestions are appreciated!

You might also like...
You have just downloaded "Messenger-app" [A lightweight, minimalistic real-time chat application]

MESSENGER-APP You have just downloaded "Messenger-app" [A lightweight, minimalistic real-time chat application] Setup To get it working, follow these

Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics (functional) API that doesn't cause vendor lock-in.

Metrics Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics API that doesn't cau

Docker-magento2 - 🐳 Docker containers with all required Magento 2 dependencies installed available as FPM through Nginx and CLI

Magento 2 Docker A collection of Docker images for running Magento 2 through nginx and on the command line. Quick Start cp composer.env.sample compose

This component provides a collection of functions/classes using the symfony/intl package when the Intl extension is not installed.

Symfony Polyfill / Intl: ICU This package provides fallback implementations when the Intl extension is not installed. It is limited to the "en" locale

Installed composer packages info

PackageInfo This package was highly inspired from ocramius/package-versions I needed some methods to read data from the composer.lock file fast...this

Composer addon to efficiently get installed packages' version numbers

Package Versions composer/package-versions-deprecated is a fully-compatible fork of ocramius/package-versions which provides compatibility with Compos

This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.

Kirby 3 Many To Many Field This plugin allows you to create many-to-many relationships between pages in Kirby.

Ask your friends to send you an anonymous message without knowing them

Ask your friends to send you an anonymous message without knowing them. 🤪😆😁🥳

Just the stats I want, maybe you want them too

SKCDEV Easy Digital Downloads Stats This plugin adds a new "SKCDEV EDD Stats" report tab to the EDD Reports tabs. Just the stats I want, maybe you wan

Releases(1.0.0)
Owner
Leon
freelancer
Leon
Allows installing Drupal extensions event if not compatible with installed drupal/core package

mglaman/composer-drupal-lenient Lenient with it, Drupal 10 with it. Why? The Drupal community introduced a lenient Composer facade that modified the d

Matt Glaman 14 Dec 18, 2022
Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker.

symfony-api Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker. ⚙️ Depl

Oleksii Velychko 1 Nov 20, 2022
Optional package for Laravel to generate social share links.

Laravel Share Share links exist on almost every page in every project, creating the code for these share links over and over again can be a pain in th

Joren Van Hocht 466 Dec 21, 2022
Greyhole uses Samba to create a storage pool of all your available hard drives, and allows you to create redundant copies of the files you store.

Greyhole Greyhole is an application that uses Samba to create a storage pool of all your available hard drives (whatever their size, however they're c

Guillaume Boudreau 245 Dec 18, 2022
Parse DSN strings into value objects to make them easier to use, pass around and manipulate

DSN parser Parse DSN strings into value objects to make them easier to use, pass around and manipulate. Install Via Composer composer require nyholm/d

Tobias Nyholm 77 Dec 13, 2022
Make and publish extensions.

Deutsch English Svenska Publish 0.8.59 Make and publish extensions. How to make an extension Start with a feature, language or theme. This will show y

Anna 3 Nov 5, 2022
A web app for the resolution of a mobile game in wich you have 4 images and a list of letters, then a few boxes to fill with the word connecting the four images.

4images_1mot_solutions A web app for the resolution of a mobile game in wich you have 4 images and a list of letters, then a few boxes to fill with th

FOTSO Claude 3 Jan 13, 2022
Download this Plugin and you will have Hive MC server in your own!

Your-Own-Hive Version: v1.9.0 Murder Mystery Update Next Update: Survival Games This Plugin has all the essentials with HiveMC! Updates Every Day! Pla

null 16 Sep 9, 2022
The simplest way to create a dynamic sitemap for your self-coded website which you have made by using PHP/HTML/CSS/Js etc... Scripts.

Sitemap_index.xml The simplest way to create a dynamic sitemap for your self-coded website which you have made by using PHP/HTML/CSS/Js etc... Scripts

Tanish Raj 1 Oct 16, 2021