Skip to content

Instantly share code, notes, and snippets.

@PaulMaynard
Last active August 29, 2015 13:57
Show Gist options
  • Save PaulMaynard/9572416 to your computer and use it in GitHub Desktop.
Save PaulMaynard/9572416 to your computer and use it in GitHub Desktop.
Checks the size of all images on page to ensure they are the same as the dimensions of the image file
[].slice.call(document.getElementsByTagName('img')).map(function(i) {
var src = i.src, i2 = new Image();
i2.src = src
return {
src: src,
i1: i,
i2: i2
}
}).filter(function(i) {
return !(i.i1.width === i.i2.width || i.i1.height === i.i2.height)
}).map(function(i) {
return i.i1.alt + ': ' + /^.*\/([^\/]*)$/.exec(i.src)[1] + ", width: " + i.i2.width + ", height: " + i.i2.height
}).join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment