2022-05-12 01:03:40 +00:00
|
|
|
import jpegsuite, os, pixie, strformat, strutils
|
2020-11-28 04:51:08 +00:00
|
|
|
|
2022-05-11 22:54:02 +00:00
|
|
|
createDir("tests/fileformats/jpeg/generated")
|
|
|
|
createDir("tests/fileformats/jpeg/diffs")
|
2022-05-07 19:19:15 +00:00
|
|
|
|
2022-05-11 22:54:02 +00:00
|
|
|
for file in jpegSuiteFiles:
|
|
|
|
let img = readImage(file)
|
2022-05-07 19:19:15 +00:00
|
|
|
|
2022-05-11 22:54:02 +00:00
|
|
|
let genFile = file.replace("masters", "generated").replace(".jpg", ".png")
|
|
|
|
img.writeFile(genFile)
|
2022-05-07 19:19:15 +00:00
|
|
|
|
2022-05-26 04:56:45 +00:00
|
|
|
if execShellCmd(&"magick {file} -auto-orient {genFile}") != 0:
|
2022-05-07 19:19:15 +00:00
|
|
|
echo "fail"
|
|
|
|
|
|
|
|
var img2 = readImage(genFile)
|
|
|
|
let (score, diff) = img2.diff(img)
|
2022-05-11 22:54:02 +00:00
|
|
|
|
|
|
|
let diffFile = file.replace("master", "diff").replace(".jpg", ".png")
|
2022-05-07 19:19:15 +00:00
|
|
|
diff.writeFile(diffFile)
|
|
|
|
|
|
|
|
if score > 1:
|
|
|
|
echo "!!!!!!!!!!!!!! FAIL !!!!!!!!!!!!!"
|
|
|
|
echo &"{score:2.3f}% ... {file}"
|