Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

image processing library that can downscale, compress and convert images using PHP-GD native functions

NotificationsYou must be signed in to change notification settings

leongrdic/php-imgman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 theoutput() 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 = (newImgMan)    ->fromDataUrl($dataUrlFromJS)    ->cacheExif()    ->downscale(2048)    ->rotateFromExif()// rotating after downscaling should use less memory and be a bit faster    ->output(ImageFormat::jpeg, quality:75)    ->toString();
(newImgMan)    ->fromFile('example.png')    ->downscale(1920,1080)    ->output(ImageFormat::png)    ->toFile();// use input filename (replace original file)
$dataUrl = (newImgMan)    ->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!

About

image processing library that can downscale, compress and convert images using PHP-GD native functions

Topics

Resources

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp