PHPackages                             magnum34/thumbnail-so - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. magnum34/thumbnail-so

ActiveLibrary

magnum34/thumbnail-so
=====================

PHP Thumnail so is image manipulation library providing.

v1.1.0(5y ago)012MITPHPPHP &gt;=7.1.0

Since Apr 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Magnum34/Thumbnail-so)[ Packagist](https://packagist.org/packages/magnum34/thumbnail-so)[ RSS](/packages/magnum34-thumbnail-so/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Thumbnail So
============

[](#thumbnail-so)

[![Build Status](https://camo.githubusercontent.com/d38975c1b334875d51e9f182e68f0c5da5c56391fa0da7a88f08a55062c74527/68747470733a2f2f7472617669732d63692e636f6d2f4d61676e756d33342f5468756d626e61696c2d736f2e7376673f6272616e63683d6d61696e)](https://travis-ci.com/Magnum34/Thumbnail-so)[![codecov](https://camo.githubusercontent.com/937f2a524d9345c524be69630f43cf3ab1550586055f9ca1c7970aef328dad9e/68747470733a2f2f636f6465636f762e696f2f67682f4d61676e756d33342f5468756d626e61696c2d736f2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d754e79646d4a52467642)](https://codecov.io/gh/Magnum34/Thumbnail-so)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Thumbnail So is a PHP image manipulation library resize (scale) to max side for jpeg and png. Expandable to different file storage providers e.g Dropbox. Default is Local storage, AWS S3.

Getting started
---------------

[](#getting-started)

- [Requirements](#requirements)
- [Setup](#setup)
- [Methods](#methods)
- [Save Local Storage](#save-local-storage)
- [Save AWS S3](#save-aws-s3)
- [Extension new providers](#extension-new-providers)

Requirements
------------

[](#requirements)

- PHP &gt;=7.1

Setup
-----

[](#setup)

```
composer require magnum34/thumbnail-so

```

Methods
-------

[](#methods)

1. resizeToMaxSide($max)

- max - The size of the long side of the image after scaling is max pixels.

2. save($type, $directorty, $filename)

- type - provider type default: local, s3.
- directory - target path to save.

Save Local Storage
------------------

[](#save-local-storage)

Example:

```
use ThumbnailSo\ThumbnailSo;

$img = new ThumbnailSo('image.jpeg');
$img->resizeToMaxSide(150);
$img->save('local', 'example', 'image');
```

Save AWS S3
-----------

[](#save-aws-s3)

```
cp .env.example .env

```

Configuration for AWS S3.

```
AWS_ACCESS_KEY_ID="PUT_THE_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY="PUT_THE_SECRET_ACCESS_KEY"
AWS_DEFAULT_REGION="PUT_THE_SELECTED_REGION_CODE"
AWS_BUCKET="PUT_YOUR_BUCKET_NAME"

```

Example:

```
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__,'.env');
$dotenv->load();

use ThumbnailSo\ThumbnailSo;

$img = new ThumbnailSo('image.jpeg');
$img->resizeToMaxSide(150);
$img->save('s3', 'example', 'image');
```

Extension new providers
-----------------------

[](#extension-new-providers)

Example Dropbox:

1. Install Dropbox PHP SDK -&gt;

```
php composer require kunalvarma05/dropbox-php-sdk

```

2. Create Driver for Dropbox.

DropboxDriver.php

```
