Created
September 17, 2012 18:18
-
-
Save jfsiii/3738879 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 called | |
* @returns {JSON} {"result": "..."} | |
*/ | |
jQuery.getJSON('//imageinfo.jit.su/?cb=?', { | |
url: 'http://www.exif.org/samples/olympus-c960.jpg', | |
// Your `format` string will typically be much simpler. This expression just | |
// does some work to create a string with every possible variable. | |
format: ( | |
// === PERCENTAGES === | |
'%b%c%d%e%f%g%h%i%k%l%m%n%o%p%q%r%s%t%u%w%x%y%z%A%C%D%G%H%M%O%P%Q%S%T%W%Y%Z%@%#' + | |
// === EXTRAS === | |
'%[base]%[channels]%[colorspace]%[copyright]%[depth]%[directory]' + | |
'%[extension]%[group]%[height]%[kurtosis]%[magick]%[max]%[mean]%[min]' + | |
'%[name]%[opaque]%[page]%[resolution.x]%[resolution.y]%[zero]%[scene]' + | |
'%[size]%[skewness]%[standard-deviation]%[type]%[unique]%[version]%[width]%[*]' + | |
// === EXIF === | |
'%[EXIF:*]' | |
) | |
.match(/(%[^%]+)/g) | |
.map(function (s) { return "%"+s+":\t"+s; }) | |
.join('\n') | |
}, function (r) { | |
console.log(r.result); | |
}) |
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
%b: 87599B | |
%c: | |
%d: //www.exif.org/samples | |
%e: jpg | |
%f: olympus-c960.jpg | |
%g: 640x480+0+0 | |
%h: 480 | |
%i: olympus-c960.jpg | |
%k: 83425 | |
%l: | |
%m: JPEG | |
%n: 1 | |
%o: | |
%p: 0 | |
%q: 16 | |
%r: DirectClassRGB | |
%s: 0 | |
%t: olympus-c960 | |
%u: | |
%w: 640 | |
%x: 72 PixelsPerInch | |
%y: 72 PixelsPerInch | |
%z: 8 | |
%A: False | |
%C: JPEG | |
%D: Undefined | |
%G: 640x480 | |
%H: 480 | |
%M: http://www.exif.org/samples/olympus-c960.jpg | |
%O: +0+0 | |
%P: 640x480 | |
%Q: 90 | |
%S: 2147483647 | |
%T: 0 | |
%W: 640 | |
%Y: +0 | |
%Z: | |
%@: 640x480+0+0 | |
%#: f59213cb43c2eac555c72c0530cbe7308f370e3acf33b41cfe02649bdd89c0f6 | |
%[base]: olympus-c960 | |
%[channels]: rgb | |
%[colorspace]: RGB | |
%[copyright]: Copyright (C) 1999-2011 ImageMagick Studio LLC | |
%[depth]: 8 | |
%[directory]: //www.exif.org/samples | |
%[extension]: jpg | |
%[group]: 0x0 | |
%[height]: 480 | |
%[kurtosis]: -0,930479 | |
%[magick]: JPEG | |
%[max]: 65535 | |
%[mean]: 29173 | |
%[min]: 0 | |
%[name]: jpg | |
%[opaque]: true | |
%[page]: 1 | |
%[resolution.x]: | |
%[resolution.y]: | |
%[zero]: | |
%[scene]: 0 | |
%[size]: 87,6KBB | |
%[skewness]: 0,182894 | |
%[standard-deviation]: 15642,2 | |
%[type]: | |
%[unique]: | |
%[version]: ImageMagick 6.7.3-1 2011-11-14 Q16 http://www.imagemagick.org | |
%[width]: 640 | |
%[*]: base=olympus-c960 | |
channels=rgb | |
colorspace=RGB | |
copyright=Copyright (C) 1999-2011 ImageMagick Studio LLC | |
date:create=2012-09-17T17:28:40+00:00 | |
date:modify=2012-09-17T17:28:40+00:00 | |
depth=8 | |
directory=//www.exif.org/samples | |
extension=jpg | |
group=0x0 | |
height=480 | |
jpeg:colorspace=2 | |
jpeg:sampling-factor=2x2,1x1,1x1 | |
kurtosis=-0,930479 | |
magick=JPEG | |
max=65535 | |
mean=29173 | |
min=0 | |
name=jpg | |
opaque=true | |
page=1 | |
scene=0 | |
signature=f59213cb43c2eac555c72c0530cbe7308f370e3acf33b41cfe02649bdd89c0f6 | |
size=87,6KBB | |
skewness=0,182894 | |
standard-deviation=15642,2 | |
version=ImageMagick 6.7.3-1 2011-11-14 Q16 http://www.imagemagick.org | |
width=640 | |
%[EXIF:*]: exif:ColorSpace=1 | |
exif:ComponentsConfiguration=1, 2, 3, 0 | |
exif:CompressedBitsPerPixel=1/1 | |
exif:Compression=6 | |
exif:DateTime=2000:11:08 20:14:38 | |
exif:DateTimeDigitized=2000:11:07 10:41:43 | |
exif:DateTimeOriginal=2000:11:07 10:41:43 | |
exif:ExifImageLength=960 | |
exif:ExifImageWidth=1280 | |
exif:ExifOffset=274 | |
exif:ExifVersion=48, 50, 49, 48 | |
exif:ExposureBiasValue=0/10 | |
exif:ExposureProgram=2 | |
exif:ExposureTime=1/345 | |
exif:FileSource=3 | |
exif:Flash=0 | |
exif:FlashPixVersion=48, 49, 48, 48 | |
exif:FNumber=80/10 | |
exif:FocalLength=56/10 | |
exif:ImageDescription=OLYMPUS DIGITAL CAMERA | |
exif:InteroperabilityIndex=R98 | |
exif:InteroperabilityOffset=958 | |
exif:InteroperabilityVersion=48, 49, 48, 48 | |
exif:ISOSpeedRatings=125 | |
exif:JPEGInterchangeFormat=2012 | |
exif:JPEGInterchangeFormatLength=5145 | |
exif:LightSource=0 | |
exif:Make=OLYMPUS OPTICAL CO.,LTD | |
exif:MakerNote=79, 76, 89, 77, 80, 0, 1, 0, 8, 0, 1, 2, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0, 2, 2, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 4, 2, 5, 0, 1, 0, 0, 0, 124, 3, 0, 0, 5, 2, 5, 0, 1, 0, 0, 0, 132, 3, 0, 0, 6, 2, 8, 0, 6, 0, 0, 0, 140, 3, 0, 0, 7, 2, 2, 0, 5, 0, 0, 0, 152, 3, 0, 0, 9, 2, 7, 0, 32, 0, 0, 0, 158, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 152, 2, 0, 0, 100, 0, 0, 0, 229, 254, 244, 253, 197, 253, 245, 254, 27, 254, 250, 253, 83, 82, 56, 55, 52, 0, 79, 76, 89, 77, 80, 85, 83, 32, 68, 73, 71, 73, 84, 65, 76, 32, 67, 65, 77, 69, 82, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | |
exif:MaxApertureValue=3/1 | |
exif:MeteringMode=5 | |
exif:Model=C960Z,D460Z | |
exif:Orientation=1 | |
exif:ResolutionUnit=2 | |
exif:SceneType=1 | |
exif:Software=OLYMPUS CAMEDIA Master | |
exif:UserComment=0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 | |
exif:XResolution=72/1 | |
exif:YCbCrPositioning=2 | |
exif:YResolution=72/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment