Giter Club home page Giter Club logo

blitline_javascript_lib's Introduction

Important!

Blitline Javascript Library has changed...

Specifically:

  • If you are using an older version, the completed callback returns results, not an array of images. The results corresponds to exactly what would be returned by long polling or the Blitline postback.
  • Long polling is used now for better performance
  • Simpler example and better handling of images
  • Added WTFPL (http://en.wikipedia.org/wiki/WTFPL) license to blitline_cors.js

Using Blitline Javascript

Just include blitline_cors.js in your html!

The blitline_cors.js file allows a simpler way to commit jobs to Blitline via javascript. Although Blitline was designed to be used by backends to handle image processing, many people have been expressed interest in scripting blitline jobs via javascript.

What's the point of it?

Specifically, if you have a big bucket of images you want processed, you can write javascript to process them instead of implementing a ruby or nodejs or whatever language app. Imagine you are writing a script for someone else, and you don't know if they are Mac/PC or if they even know how to install ruby/node/whatever. You can write it in javascript and be sure that they will be able to execute it.

Warning/Reminder! Obviously too, you don't want to give clients your Blitline Application ID, because thats YOUR secret. If you give it to clients they could process stuff under your account. Blitline supports signed expiring tokens so you can give the clients tokens which expire which allows them to process an item under your App ID, without giving them your App ID (see http://blog.blitline.com/day/2011/12/27 for more details).

Why is stuff called CORS?

Behind the scenes, the cross domain posting happens via CORS

Blitline supports CORS headers for cross domain ajax/posts and ajax/gets, which makes it easy for browsers to submit jobs to Blitline.

Browser Support? Which browsers will it just "work" on?

  • Safari : YES
  • Chrome : YES
  • Firefox: YES
  • IE8+ : YES
  • IE7- : NO (Sorry IE7ers and below, you are on your own)

Is there any way other than CORS?

Yes. If you want to use something that uses IFRAME messaging, like http://benalman.com/code/projects/jquery-postmessage/docs/files/jquery-ba-postmessage-js.html, we have some support for this too. Write us at [email protected] and we can give you some help guidance.

How do I use it?

There is only two files, just download them and look at them. I think it's pretty self explanatory. You create a Blitline object, then submit jobs with some callback events and the blitline_cors.js library will take care of everything else for you.

##Simple Example: // Set your own App ID; var myAppId = "YOUR_APP_ID"

// Create Blitline Object
var blitline = new Blitline();

// Add events for handling submitted and completed
var events = {
	completed : function(results, error) {
		alert("Job completed:" + JSON.stringify(results));
	}
}

// Build your JSON
var json = { "application_id": myAppId, "src" : "http://www.google.com/logos/2011/yokoyama11-hp.jpg", "functions" : [ {"name": "blur", "params" : {"radius" : 0.0,  "sigma" : 2.0}, "save" : { "image_identifier" : "MY_CLIENT_ID" }} ]};

// Submit it
blitline.submit(JSON.stringify(json), events);

Otherwise, check out cors.html for a more complete example.

What are the requirements?

The blitline_cors.js javascript library relies on JQuery, and Underscore.js. You must have both of these on your page for the blitline javascript library to work.

Licensing?

The project is licensed under the http://en.wikipedia.org/wiki/WTFPL license.

blitline_javascript_lib's People

Contributors

blitline-dev avatar

Watchers

 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.