| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>CSS Images Module Level 3: image-orientation: none</title> |
| <script src=/common/get-host-info.sub.js></script> |
| <link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org"> |
| <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/5165"> |
| <link rel="match" href="reference/image-orientation-none-cross-origin-ref.html"> |
| <meta name=fuzzy content="10;100"> |
| <style> |
| img {display: none} |
| canvas { |
| width: 100px; |
| height: 100px; |
| } |
| </style> |
| <script> |
| const src1 = 'support/exif-orientation-1-ul.jpg'; |
| const src2 = 'support/exif-orientation-3-lr.jpg'; |
| function toCors(src) { |
| return src.replace(new URL(src).origin, get_host_info().HTTP_REMOTE_ORIGIN) |
| } |
| function createImage({cors, src, orientation}) { |
| const img = document.createElement('img'); |
| img.src = src |
| if (cors) |
| img.src = toCors(img.src) |
| img.style.imageOrientation = orientation |
| img.style.display = 'none' |
| document.body.appendChild(img) |
| return img |
| } |
| |
| window.onload = () => { |
| const images = { |
| red: [ |
| createImage({cors: true, src: src2, orientation: 'from-image', shouldBeRotated: true}), |
| createImage({cors: true, src: src2, orientation: 'none', shouldBeRotated: true}), |
| createImage({cors: false, src: src2, orientation: 'from-image', shouldBeRotated: true}), |
| ], |
| green: [ |
| createImage({cors: true, src: src1, orientation: 'from-image', shouldBeRotated: false}), |
| createImage({cors: true, src: src1, orientation: 'none', shouldBeRotated: false}), |
| createImage({cors: false, src: src1, orientation: 'from-image', shouldBeRotated: false}), |
| createImage({cors: false, src: src1, orientation: 'none', shouldBeRotated: false}), |
| createImage({cors: false, src: src2, orientation: 'none', shouldBeRotated: false}), |
| ] |
| } |
| |
| const dimension = 5 |
| |
| Object.keys(images).forEach(key => { |
| const p = document.createElement('p') |
| p.innerText = `The following canvases should be ${key}` |
| document.body.appendChild(p) |
| images[key].forEach(image => { |
| const canvas = document.createElement('canvas') |
| canvas.width = canvas.height = dimension |
| const ctx = canvas.getContext('2d') |
| ctx.drawImage(image, 0, 0) |
| document.body.appendChild(canvas) |
| }) |
| }) |
| |
| } |
| |
| </script> |
| </head> |
| <body> |
| </body> |
| <script> |
| [src1, src2].forEach(src => { |
| const img = document.createElement('img') |
| img.src = src |
| const imgCors = document.createElement('img') |
| imgCors.src = src |
| imgCors.src = toCors(imgCors.src) |
| document.body.appendChild(img) |
| document.body.appendChild(imgCors) |
| }) |
| </script> |
| </html> |