Skip to content

Commit

Permalink
Added EXIF Orientation test
Browse files Browse the repository at this point in the history
iOS looks at the EXIF Orientation flag in jpgs and rotates the image
accordingly. Looks like most desktop browsers just ignore this data.
  • Loading branch information
psayre-sc committed Jun 6, 2012
1 parent 0338d1d commit d17576a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions feature-detects/exif-orientation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// EXIF Orientation test
// iOS respects EXIF Orientation flag in jpgs, while other browsers do not
// By: Paul Sayre


(function(){

var img = new Image();

img.onerror = function() {
Modernizr.addTest('exif-orientation', function () { return false; });
};

img.onload = function() {
Modernizr.addTest('exif-orientation', function () { return img.width !== 2; });
};

// There may be a way to shrink this more, it's a 1x2 white jpg with the orientation flag set to 6
img.src = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAASUkqAAgAAAABABIBAwABAAAABgASAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAABAAIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+/iiiigD/2Q==";

})();

0 comments on commit d17576a

Please sign in to comment.