2017 © Pedro Peláez
 

library image-uploader

Image uploader and resizer

image

pensiero/image-uploader

Image uploader and resizer

  • Tuesday, February 14, 2017
  • by pensiero
  • Repository
  • 3 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Image Upload

API based service that allow to save, resize and read images, (*1)

Features

  • [x] Save on Filesystem
  • [x] Save on AWS
  • [x] Possibility to add Validators
  • [x] Possibility to add Filters
  • [x] PHP7 strict mode
  • [x] Link with public Postman collection
  • [ ] Unit testing
  • [ ] Submit on packagist (composer)
  • [ ] Host the demo somewhere
  • [ ] Auth token API protection

Configuration

Environment variables allowed: - SAVE_HANDLER: (filesystem|aws) where you will save the images - AWS_ACCESS_KEY_ID: - AWS_SECRET_ACCESS_KEY: - AWS_REGION: - AWS_BUCKET: - OPTIMIZE: (0|1) strip exif data in order to reduce image size - MAX_DIMENSIONS: (example: 4096x4096) maximum allowed dimensions - MAX_SIZE: (example: 10240) maximum allowed size in kb - ALLOWED_DIMENSIONS: (example: 1400x460;1280x460;800x600) dimensions allowed when requesting a resize version of a previously uploaded image, (*2)

Usage via API

Run in Postman, (*3)

In order to receive a JSON response, you should add the following headers: - Content-Type: application/json - Accept: application/json; charset=utf-8, (*4)

We are supposing that you uploaded this application on theappleisonthetable.com, (*5)

GET https://theappleisonthetable.com/

Return info about a previously uploaded image, (*6)

Parameters: - id: (optional: integer) id of a previously uploaded image, (*7)

Example GET data: {}, (*8)

Example response:, (*9)

  {
    "ping": "pong"
  }

Example GET data: {"id": "5897209a9325f7-78554697"}, (*10)

Example response:, (*11)

  {
    "status_code": 200,
    "id": "5897209a9325f7-78554697",
    "url": "http://image-uploader.dev/i/5897209a9325f7-78554697_0_0.jpg",
    "url_dynamic": "http://image-uploader.dev/i/5897209a9325f7-78554697_#WIDTH#_#HEIGHT#.jpg",
    "width": null,
    "height": null
  }

POST https://theappleisonthetable.com/

Upload an image, (*12)

Parameters: - source: (required: url|base64 string|uploaded file) you can send a remote url, an image base64 encoded (without new lines in JSON) or upload a file (see an example in the public/upload.php - width: (optional: integer) if specified, the original image will be resized to the specified width before uploading it - height: (optional: integer) if specified, the original image will be resized to the specified height before uploading it, (*13)

Note: if you specify only the width or the height param, the image will be proportionally resized, (*14)

Example POST data: {"source": "...very long base64 string..."}, (*15)

Example response:, (*16)

  {
    "status_code": 200,
    "id": "5898c96c4a2d62-52410036",
    "url": "http://image-uploader.dev/i/5898c96c4a2d62-52410036_0_0.jpg",
    "url_dynamic": "http://image-uploader.dev/i/5898c96c4a2d62-52410036_#WIDTH#_#HEIGHT#.jpg",
    "width": null,
    "height": null
  }

Demo

Hosting in progress..., (*17)

Examples

If you want to use directly the Image object in your application (and not as a standalone API service), you can find some examples inside the public/examples directory., (*18)

The Versions

14/02 2017

dev-master

9999999-dev https://github.com/pensiero/image-uploader

Image uploader and resizer

  Sources   Download

BSD-3-Clause

The Requires

 

14/02 2017

v0.1.0

0.1.0.0 https://github.com/pensiero/image-uploader

Image uploader and resizer

  Sources   Download

BSD-3-Clause

The Requires

 

08/02 2017

v0.0.2

0.0.2.0 https://github.com/pensiero/image-uploader

Image uploader and resizer

  Sources   Download

BSD-3-Clause

The Requires

 

06/02 2017

v0.0.1

0.0.1.0 https://github.com/pensiero/image-uploader

Image uploader and resizer

  Sources   Download

BSD-3-Clause

The Requires