pixie/tests/validate_jpeg.nim
2022-05-25 23:56:45 -05:00

24 lines
647 B
Nim

import jpegsuite, os, pixie, strformat, strutils
createDir("tests/fileformats/jpeg/generated")
createDir("tests/fileformats/jpeg/diffs")
for file in jpegSuiteFiles:
let img = readImage(file)
let genFile = file.replace("masters", "generated").replace(".jpg", ".png")
img.writeFile(genFile)
if execShellCmd(&"magick {file} -auto-orient {genFile}") != 0:
echo "fail"
var img2 = readImage(genFile)
let (score, diff) = img2.diff(img)
let diffFile = file.replace("master", "diff").replace(".jpg", ".png")
diff.writeFile(diffFile)
if score > 1:
echo "!!!!!!!!!!!!!! FAIL !!!!!!!!!!!!!"
echo &"{score:2.3f}% ... {file}"