Last active
April 11, 2020 09:11
-
-
Save skalee/7dc467bf1f097e5b719e05c2ce877251 to your computer and use it in GitHub Desktop.
Tester for broken EXIF autorotate in Jimp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------ | |
testing: Landscape_1.jpg | |
orientation: 1 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
sleeping... 500ms | |
orientation: 1 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
orientation: 1 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
------------ | |
testing: Landscape_2.jpg | |
orientation: 2 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
sleeping... 500ms | |
orientation: 2 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
orientation: 2 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
------------ | |
testing: Landscape_3.jpg | |
orientation: 3 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
sleeping... 500ms | |
orientation: 3 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
orientation: 3 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
------------ | |
testing: Landscape_4.jpg | |
orientation: 4 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
sleeping... 500ms | |
orientation: 4 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
orientation: 4 | |
width: 600 | |
height: 450 | |
non-0 bytes: yes | |
------------ | |
testing: Landscape_5.jpg | |
orientation: 5 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
sleeping... 500ms | |
orientation: 5 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
orientation: 5 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
------------ | |
testing: Landscape_6.jpg | |
orientation: 6 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
sleeping... 500ms | |
orientation: 6 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
orientation: 6 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
------------ | |
testing: Landscape_7.jpg | |
orientation: 7 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
sleeping... 500ms | |
orientation: 7 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
orientation: 7 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
------------ | |
testing: Landscape_8.jpg | |
orientation: 8 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
sleeping... 500ms | |
orientation: 8 | |
width: 602 | |
height: 602 | |
non-0 bytes: no | |
orientation: 8 | |
width: 602 | |
height: 602 | |
non-0 bytes: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pathToImages = __dirname | |
const path = require("path") | |
const configure = require("@jimp/custom") | |
const types = require("@jimp/types") | |
const Jimp = configure({ | |
types: [types], | |
plugins: [ | |
require("@jimp/plugin-flip"), | |
require("@jimp/plugin-rotate"), | |
], | |
}) | |
run() | |
async function run() { | |
console.log() | |
for(let i = 1; i <= 8; i++) { | |
let filePath = path.join(pathToImages, `Landscape_${i}.jpg`) | |
await testFile(filePath) | |
} | |
} | |
async function testFile(filePath) { | |
console.log("------------") | |
console.log(` testing: ${path.basename(filePath)}`) | |
let jimpImage = await Jimp.read(filePath) | |
inspect(jimpImage) | |
await sleep(500) | |
inspect(jimpImage) | |
await jimpImage.getBufferAsync(Jimp.AUTO) | |
inspect(jimpImage) | |
console.log("") | |
console.log("") | |
} | |
function inspect(jimpImage) { | |
console.log(`orientation: ${jimpImage._exif.tags.Orientation}`) | |
console.log(` width: ${jimpImage.getWidth()}`) | |
console.log(` height: ${jimpImage.getHeight()}`) | |
let found = false | |
for (let byte of jimpImage.bitmap.data) { | |
found = found || (byte != 0) | |
} | |
console.log(`non-0 bytes: ${found ? "yes" : "no"}` ) | |
} | |
function sleep(ms) { | |
console.log(` sleeping... ${ms}ms`) | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment