2022-05-12 23:47:53 +00:00
|
|
|
import jpegsuite, pixie/common, pixie/fileformats/jpeg, random, strformat
|
2022-05-05 16:19:17 +00:00
|
|
|
|
|
|
|
randomize()
|
|
|
|
|
|
|
|
for i in 0 ..< 10_000:
|
2022-05-11 22:54:02 +00:00
|
|
|
let file = sample(jpegSuiteFiles)
|
|
|
|
var data = readFile(file)
|
2022-05-05 16:19:17 +00:00
|
|
|
let
|
|
|
|
pos = rand(0 ..< data.len)
|
|
|
|
value = rand(255).uint8
|
|
|
|
data[pos] = value.char
|
2022-05-11 22:54:02 +00:00
|
|
|
echo &"{i} {file} {pos} {value}"
|
2022-05-05 16:19:17 +00:00
|
|
|
|
|
|
|
try:
|
2022-05-12 23:47:53 +00:00
|
|
|
let img = decodeJpeg(data)
|
2022-05-05 16:19:17 +00:00
|
|
|
doAssert img.height > 0 and img.width > 0
|
|
|
|
except PixieError:
|
|
|
|
discard
|
|
|
|
data = data[0 ..< pos]
|
|
|
|
try:
|
2022-05-12 23:47:53 +00:00
|
|
|
let img = decodeJpeg(data)
|
2022-05-05 16:19:17 +00:00
|
|
|
doAssert img.height > 0 and img.width > 0
|
|
|
|
except PixieError:
|
|
|
|
discard
|