Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

sharp

Powerful API for image conversion and manipulation.

This project provides a hosted API for sharp by Lovell Fuller.

We set aside the majority of any revenue generated from this API for the original OSS developers. If you are one of these devs, please check out our mission and get in touch to setup payouts and answer any questions you may have.

Use Hosted API

Examples

The following examples can all be invoked with the following curl template by changing out the example.json file:

curl -X POST -d '@example.json' \
  'https://ssfy.sh/dev/sharp'

Download image

example.json

{
  "input": "https://octodex.github.com/images/original.png"
}
curl -X POST -d '@example.json' -o out.png \
  'https://ssfy.sh/dev/sharp'

Convert png to jpeg

example.json

{
  "input": "https://octodex.github.com/images/original.png",
  "ops": [
    {
      "op": "jpeg"
    }
  ]
}
curl -X POST -d '@example.json' -o out.jpg \
  'https://ssfy.sh/dev/sharp'

Here's this example as a GET request: /?input=https://octodex.github.com/images/original.png&ops[0][op]=jpeg.

Resize and convert to webp

example.json

{
  "input": "https://octodex.github.com/images/original.png",
  "ops": [
    {
      "op": "resize",
      "options": {
        "width": 220,
        "height": 128,
        "fit": "contain"
      }
    },
    {
      "op": "webp"
    }
  ]
}
curl -X POST -d '@example.json' -o out.webp \
  'https://ssfy.sh/dev/sharp'

Blur and then flip vertically

example.json

{
  "input": "https://octodex.github.com/images/original.png",
  "ops": [
    {
      "op": "blur",
      "sigma": 10
    },
    {
      "op": "flip"
    }
  ]
}
curl -X POST -d '@example.json' -o out.png \
  'https://ssfy.sh/dev/sharp'

Tint, remove alpha, and convert to custom png

example.json

{
  "input": "https://octodex.github.com/images/original.png",
  "ops": [
    {
      "op": "tint",
      "rgb": "#7743CE"
    },
    {
      "op": "removeAlpha"
    },
    {
      "op": "png",
      "options": {
        "compressionLevel": 7
      }
    }
  ]
}
curl -X POST -d '@example.json' -o out.png \
  'https://ssfy.sh/dev/sharp'

Get image metadata

example.json

{
  "input": "https://octodex.github.com/images/original.png",
  "ops": [
    {
      "op": "metadata"
    }
  ]
}
curl -X POST -d '@example.json' -o out.json \
  'https://ssfy.sh/dev/sharp'

output (JSON)

{
  "format": "png",
  "size": 36582,
  "width": 896,
  "height": 896,
  "space": "srgb",
  "channels": 4,
  "depth": "uchar",
  "density": 72,
  "isProgressive": false,
  "hasProfile": false,
  "hasAlpha": true
}

Image Operations

The following sharp image operations are supported.

All op names and parameters mirror the sharp docs exactly.

Input

Output

Resizing

Compositing

Image Manipulation

Color Manipulation

Channel Manipulation

License

This SaaS project was bootstrapped with Saasify.

MIT © Saasify