GithubHelp home page GithubHelp logo

neuralnoise / betty-cropper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from theonion/betty-cropper

0.0 2.0 0.0 15.38 MB

A work-in-progress image cropper.

License: MIT License

Python 74.83% HTML 5.33% JavaScript 17.75% CSS 1.09% Shell 1.00%

betty-cropper's Introduction

Betty Cropper

Build Status Coverage Status Latest Version

Get started developing:

> git clone [email protected]:theonion/betty-cropper.git
> cd betty-cropper
> virtualenv .
> source bin/activate
> pip install -e .
> pip install "file://$(pwd)#egg=betty-cropper[dev]"

To run the tests:

> py.test tests/

To run an instance of the server

First, make sure that you've installed the development packages for JPEG, PNG, etc.

> pip install betty-cropper
> betty-cropper init

Then edit the settings in betty.conf.py (if you want to use the dev server, you'll want to set DEBUG=True).

> betty-cropper syncdb        # Do the intial django sync
> betty-cropper migrate       # Migrate with south
> betty-cropper create_token  # Create an auth token, to use the API
> betty-cropper runserver

API

Currently, authentication means sending an X-Betty-Api-Key header with a value of your public token. This will likely change to something more mature in future versions.

POST an image (using the key "image") to /api/new, for example:

> curl -H "X-Betty-Api-Key: YOUR_PUBLIC_TOKEN" --form "[email protected]" http://localhost:8000/api/new

This should return JSON representing that image and its crops, for instance:

{
    "name": "Lenna.png",
    "width": 512,
    "selections": {
        "16x9": {"y1": 400, "y0": 112, "x0": 0, "x1": 512, "source": "auto"},
        "3x1": {"y1": 341, "y0": 171, "x0": 0, "x1": 512, "source": "auto"},
        "1x1": {"y1": 512, "y0": 0, "x0": 0, "x1": 512, "source": "auto"},
        "3x4": {"y1": 512, "y0": 0, "x0": 64, "x1": 448, "source": "auto"},
        "2x1": {"y1": 384, "y0": 128, "x0": 0, "x1": 512, "source": "auto"},
        "4x3": {"y1": 448, "y0": 64, "x0": 0, "x1": 512, "source": "auto"}
        },
    "height": 512,
    "credit": null,
    "id": 1
}

You can get a cropped version of this image using a URL like: http://localhost:8000/1/1x1/300.jpg.

To get the data form an image, send a GET request to /api/id, for example:

> curl -H "X-Betty-Api-Key: YOUR_PUBLIC_TOKEN" http://localhost:8000/api/1

To update the name or credit, use a PATCH on that same endpoint:

> curl -H "X-Betty-Api-Key: YOUR_PUBLIC_TOKEN" \
       -H "Content-Type: application/json" \
       -XPATCH http://localhost:8000/api/1 \
       -d '{"name":"Testing", "credit":"Some guy"}'

To update the selections used for a crop, you can POST to /api/id/ratio, for example:

> curl -H "X-Betty-Api-Key: YOUR_PUBLIC_TOKEN" \
       -H "Content-Type: application/json" \
       -XPOST http://localhost:8000/api/1/1x1 \
       -d '{"x0":1,"y0":1,"x1":510,"y1":510}'

GET /api/search, with an option "q" parameter in order to get a list of files matching that description. For example:

> curl -H "X-Betty-Api-Key: YOUR_PUBLIC_TOKEN" -XGET http://localhost:8000/api/search?q=lenna

Installation Notes

OSX

To avoid "encoder/decoder zlib unavailble" errors w/ Pillow library (OSX 10.11.2, Python 3.5.1), install zlib via homebrew before installing Pillow

brew tap homebrew/dupes
brew install zlib
brew link --force zlib

betty-cropper's People

Contributors

mparent61 avatar csinchok avatar collin avatar mikewnuk avatar kand avatar emcconville avatar

Watchers

James Cloos avatar Starbuck 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.