exif-orientation.js 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. // EXIF Orientation test
  2. // iOS looks at the EXIF Orientation flag in jpgs and rotates the image
  3. // accordingly. Looks like most desktop browsers just ignore this data.
  4. // description: www.impulseadventure.com/photo/exif-orientation.html
  5. // Bug trackers:
  6. // bugzil.la/298619 (unimplemented)
  7. // crbug.com/56845 (looks incomplete)
  8. // webk.it/19688 (available upstream but its up all ports to turn on individually)
  9. //
  10. // detect by Paul Sayre
  11. (function(){
  12. var img = new Image();
  13. img.onerror = function() {
  14. Modernizr.addTest('exif-orientation', function () { return false; });
  15. };
  16. img.onload = function() {
  17. Modernizr.addTest('exif-orientation', function () { return img.width !== 2; });
  18. };
  19. // There may be a way to shrink this more, it's a 1x2 white jpg with the orientation flag set to 6
  20. img.src = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAASUkqAAgAAAABABIBAwABAAAABgASAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAABAAIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+/iiiigD/2Q==";
  21. })();