Git Product home page Git Product logo

jpegkit-android's Introduction

JpegKitKit Header

JpegKit Header JpegKit Header

Build Status

JpegKit bridges the libjpeg-turbo C++ library into android and wraps it with an easy to use class. You can currently:

  • Retrieve metadata such as width and height
  • Rotate the JPEG 90, 180, or 270 degrees
  • Flip the JPEG horizontally
  • Flip the JPEG vertically
  • Crop the JPEG to any Rect

This is all done without decoding the JPEG to RGB. All operations on the JPEG are done in C++ space and does not touch the Java memory, allowing you to work with extremely large JPEGs without the risk of an OutOfMemoryException.

Setup

Add JpegKit to the dependencies block in your app level build.gradle:

compile 'com.camerakit:jpegkit:0.2.0'

Usage

JpegKit currently expects a JPEG parameter in the form of a byte[]. In the future you'll be able to just pass a file.

First, create a JpegTransformer:

byte[] jpeg = ...;
JpegTransformer jpegTransformer = new JpegTransformer(jpeg);

After you perform your transformations, you can get a new JPEG byte[] back:

byte[] newJpeg = jpegTransformer.getJpeg();

The getJpeg() call can only be used once. At this point our C++ libjpeg-turbo wrapper encodes the new JPEG and also disposes of the original and clears any other memory it used.

Transformations are performed in C++ right when you make the method call, as opposed to doing all after you finish with getJpeg(). The transformations will be applied in the order you make the method calls.

MetaData

You can currently retrieve a JPEGs width and height. This only decodes the JPEGs header information and is very fast.

int width = jpegTransformer.getWidth();
int height = jpegTransformer.getHeight();

Rotate

Acceptable parameters are 90, 180, or 270.

jpegTransformer.rotate(90);

Flip Horizontal or Vertical

Flip horizontal:

jpegTransformer.flipHorizontal();

Flip horizontal:

jpegTransformer.flipVertical();

Crop

Crop extends an android.graphics.Rect.

Rect cropRect = new Rect(left, top, right, bottom);
jpegTransformer.crop(cropRect);

License

JpegKit is MIT License

jpegkit-android's People

Contributors

dwillmc avatar austinkettner avatar

Watchers

 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.