Coder Social home page Coder Social logo

rrozek / image_playground Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 14.42 MB

Ideation bin for playing with images and image formats programmatically (PSD, TIFF, PNG, EPS, JPG, SVG)

License: MIT License

Dockerfile 8.37% Python 88.45% Shell 1.33% Scheme 1.84%

image_playground's Introduction

PBS Image Converter

Environment variables

Environment variables can be passed directly or via .env file provided with the repo.

For development/testing file provided is enough

DJANGO_SECRET_KEY=6@5nz8)0n+62ey!_@*3+x3%di)5q56yvio*_oujsc(oi$2$y#3
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=*

For production It should more likely look like:

DJANGO_SECRET_KEY=SomeRandomlyGeneratedString
DJANGO_DEBUG=False
DJANGO_ALLOWED_HOSTS=domain_name_of_the_server

Build

To build the dockerimage all we need to do is:

cd app
docker build -t image_api .

Run

This will create 'image_api' dockerimage. To run the http server, call:

docker run --env-file .env -p 8000:8000 --rm image_api

so, breaking it down into parts:

  1. --env-file .env pass env file
  2. -p 8000:8000 map container 8000 to host 8000 port
  3. --rm mark as remove on shutdown
  4. image_api imagename

from this point you should be able to visit 127.0.0.1:8000 and start querying for data.
There is simple testing app provided via swagger in api/swagger endpoint

Using API

Basically API expects data in following format:

POST /api/png/tiff/?output=url HTTP/1.1
Host: 127.0.0.1:8000
Content-Type: multipart/form-data; 
curl -X POST "http://127.0.0.1:8000/api/png/tiff/?output=url" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -H  "X-CSRFToken: QZE4jqhWqdiWyNZYYfoJx72G1o35HFlqYLeQfU3JMC8cEhEPlCH8F1ZC0oXLZahJ" -F "source=@174H_Cremeschminke_FACE_PAINT_HALLOWEEN_03.png;type=image/png"

accepted output values are: ['url', 'image']

in case of url request, 303 with Location is returned

HTTP/1.1 303 See Other
Location: http://127.0.0.1:8000/media/174H_Cremeschminke_FACE_PAINT_HALLOWEEN_03_by6tc5K.tiff

in case of image request, image is returned with content type valid for given API endpoint (image/png, image/tiff, image/postscript)

HTTP/1.1 200 OK
Content-Type: image/tiff
Content-Length: 42428190

image_playground's People

Contributors

rrozek avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.