magroski/bob-ross

An easy way to upload, manipulate and persist images.

v1.0.6 2022-11-28 19:38 UTC

This package is auto-updated.

Last update: 2024-11-29 00:04:21 UTC


README

This library provides an easy way to upload, manipulate and persist images.

Latest Stable Version Minimum PHP Version CircleCI GitHub license

Bob Ross

“We don't make mistakes, just happy little accidents.” - Bob Ross

Usage examples

Upload from multiple sources

$persistenceHandler = new LocalFileSystem();

$painter = new Painter($persistenceHandler);

# From upload form ($_FILE)
$painter->loadFromFileGlobal('profile_pic');

# From file system
$painter->loadFromFileSystem('/home/bob/images/happy_trees.png');

# From Uri
$painter->loadFromUri('https://joyOfPainting.com/bob.png');

Persist to different environments

# Amazon S3
$s3Handler = new S3(new Config('credentials','key','region));
$painter = new Painter($s3Handler);
$painter->save('myFolder');

# Local
$localHandler = new LocalFileSystem();
$painter = new Painter($localHandler);
$painter->save('myFolder');

Do size manipulations

$localHandler = new LocalFileSystem();
$painter = new Painter($localHandler);
$painter->loadFromFileSystem('/home/img/tree.png');

$painter->saveFixedWidth(1200, '/home/img');
$painter->saveFixedHeight(800, '/home/img');
$painter->saveMaxWidhtHeight(1920, 1080, 'home/img');
$painter->saveThumb(200, 200, '/home/img');

Convert between formats

$localHandler = new LocalFileSystem();
$painter = new Painter($localHandler);
$painter->loadFromFileSystem('/home/img/tree.png');
$painter->setImageCovert('bmp');
$painter->save('/home/img');

Change Jpeg quality

$localHandler = new LocalFileSystem();
$painter = new Painter($localHandler);
$painter->loadFromFileSystem('/home/img/tree.png');
$painter->setJpegQuality(50);
$painter->save('/home/img');