Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created September 15, 2012 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsiii/3729947 to your computer and use it in GitHub Desktop.
Save jfsiii/3729947 to your computer and use it in GitHub Desktop.
Get information about a remote image by passing a [-format string](http://www.imagemagick.org/script/escape.php) to [ImageMagick's identify command](http://www.imagemagick.org/script/identify.php)
/**
* Given an image URL and a format string, return information from ImageMagick's identify command.
* @param {String} url|uri|image The URL for the image to be analyzed
* @param {String} [format='{"width": %w, "height": %h}'] String for the the information you want in the format you want. Use variables from http://www.imagemagick.org/script/escape.php
* @param {String} [callback|cb] Name of the function you want to be ca
* @returns {JSON} {"result": "..."}
*/
// omit the `format` argument to use the default, JSON-ready, response
$.getJSON('//imageinfo.jit.su/?cb=?', {
url: 'http://nodejs.org/logo.png',
}, function (r) {
var imageinfo = JSON.parse(r.result);
console.log(imageinfo); // { width: 245, height: 66 }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment