GithubHelp home page GithubHelp logo

photon-core's Introduction

photon-core

On the fly photo processing

Photon-core provides a JAX-RS resource (com.thousandmemories.photon.core.PhotoResource) that processes (resizes, rotates, and crops) image files on the fly.

Read more about why we built it on our blog post (TODO: link blog post after it's live) or see it in use in an example at https://github.com/1000Memories/photon-example

PhotoResource

PhotoResource takes a path like /1234.jpg;w=200;r=180;c=130,60,200,300, fetches the image named 1234.jpg using a PhotoProvider, processes the image according the matrix parameters, and spits out the resulting image.

Matrix parameters

  • w=200: Resizes the image to be 200px wide
  • r=180: Rotates the image 90 degrees clockwise (90, 180, and 270 are the available rotation angles)
  • c=130,60,200,300: Crops the image 130px from the left, 60px from the top, with a width of 200px and a height of 300px.

PhotoProvider

PhotoResource's contructor takes an instance of PhotoProvider, which is responsible for finding the image based on the name it's given and returning an InputStream that will yield its contents. This will most often mean looking up a file in a blob store (e.g. S3 or a file system).

An example that fetches the the avatar for the named Twitter user:

public class TwitterPhotoProvider implements PhotoProvider {
    @Override
    public InputStream getPhotoInputStream(String path) throws IOException {
        return new URL("https://api.twitter.com/1/users/profile_image?size=original&screen_name=" + path).openStream();
    }
}

photon-core's People

Contributors

michaelfairley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

photon-core's Issues

Convert to greyscale

One common application for sites is to use photon for responsive images (e.g. images loaded on iPhone are smaller in dimension and file size than that of a desktop monitor). Typically, you'd want to load a low resolution image first to act as a placeholder and have it replaced with the right resolution image later.

Is it possible to use photon to generate a low resolution image that's greyscale? The benefit is that it'd be a smaller file to load (compared to color images) and provide an feel that the site is fast to load.

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.