Created
September 15, 2012 21:51
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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