UNPKG

modernizr

Version:

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

44 lines (37 loc) 2.22 kB
/*! { "name": "EXIF Orientation", "property": "exiforientation", "tags": ["image"], "async": true, "authors": ["Paul Sayre"], "notes": [{ "name": "Article by Dave Perrett", "href": "http://recursive-design.com/blog/2012/07/28/exif-orientation-handling-is-a-ghetto/" },{ "name": "Article by Calvin Hass", "href": "http://www.impulseadventure.com/photo/exif-orientation.html" }] } !*/ /* DOC Detects support for EXIF Orientation in JPEG images. iOS looks at the EXIF Orientation flag in JPEGs and rotates the image accordingly. Most desktop browsers just ignore this data. */ define(['Modernizr', 'addTest'], function( Modernizr, addTest ) { // Bug trackers: // bugzil.la/298619 (unimplemented) // crbug.com/56845 (looks incomplete) // webk.it/19688 (available upstream but its up all ports to turn on individually) Modernizr.addAsyncTest(function() { var img = new Image(); img.onerror = function() { addTest('exiforientation', false, { aliases: ['exif-orientation'] }); }; img.onload = function() { addTest('exiforientation', img.width !== 2, { aliases: ['exif-orientation'] }); }; // 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=="; }); });