A simple image host
Find a file
2020-06-07 12:56:32 -05:00
src Add a concept of 'processors' to allow multiple image transformations 2020-06-07 12:51:45 -05:00
.gitignore A Simple duplicate-resolving image host 2020-06-06 16:02:26 -05:00
Cargo.lock Add endpoint for downloading remote images 2020-06-07 10:59:58 -05:00
Cargo.toml Add endpoint for downloading remote images 2020-06-07 10:59:58 -05:00
client.py A Simple duplicate-resolving image host 2020-06-06 16:02:26 -05:00
LICENSE Add license, readme 2020-06-06 21:01:04 -05:00
README.md Add note of processors to readme 2020-06-07 12:56:32 -05:00
test.png A Simple duplicate-resolving image host 2020-06-06 16:02:26 -05:00

pict-rs

a simple image hosting service

Usage

Running

$ ./pict-rs --help
pict-rs 0.1.0

USAGE:
    pict-rs [OPTIONS] --addr <addr> --path <path>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -a, --addr <addr>        The address and port the server binds to, e.g. 127.0.0.1:80
    -f, --format <format>    An image format to convert all uploaded files into, supports 'jpg' and 'png'
    -p, --path <path>        The path to the data directory, e.g. data/

Example:

Running on all interfaces, port 8080, storing data in /opt/data

$ ./pict-rs -a 0.0.0.0:8080 -p /opt/data

Running locally, port 9000, storing data in data/, and converting all uploads to PNG

$ ./pict-rs -a 127.0.0.1:9000 -p data/ -f png

API

pict-rs offers four endpoints:

  • POST /image for uploading an image. Uploaded content must be valid multipart/form-data with an image array located within the images[] key

    This endpoint returns the following JSON structure on success with a 201 Created status

    {
        "files": [
            {
                "delete_token": "JFvFhqJA98",
                "file": "lkWZDRvugm.jpg"
            },
            {
                "delete_token": "kAYy9nk2WK",
                "file": "8qFS0QooAn.jpg"
            },
            {
                "delete_token": "OxRpM3sf0Y",
                "file": "1hJaYfGE01.jpg"
            }
        ],
        "msg": "ok"
    }
    
  • GET /image/download?url=... Download an image from a remote server, returning the same JSON payload as the POST endpoint

  • GET /image/{file} for getting a full-resolution image. file here is the file key from the /image endpoint's JSON

  • GET /image/{transformations...}/{file} get a file with transformations applied. existing transformations include

    • identity: apply no changes
    • blur{float}: apply a gaussian blur to the file
    • {int}: produce a thumbnail of the image fitting inside an {int} by {int} square An example of usage could be GET /image/256/blur3.0/asdf.png, which would create a 256x256px thumbnail and blur it
  • DELETE /image/{delete_token}/{file} to delete a file, where delete_token and file are from the /image endpoint's JSON

Contributing

Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the AGPLv3.

License

Copyright © 2020 Riley Trautman

pict-rs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

pict-rs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of pict-rs.

You should have received a copy of the GNU General Public License along with pict-rs. If not, see http://www.gnu.org/licenses/.