# "Malformed bytes: the module's kind, not runtime": a real JPEG cut three# bytes into its SOF0 frame header, handed to pdf.loadImage.import"pdf.j"as pdf;
use io;
use binary;
use encoding;
use images;
def jpeg asbytesinitimages.encode("jpeg", images.create(64, 64));
def sof asbytesinitencoding.fromText("hex", "ffc0"); # SOF0def at asintinitbinary.indexOf($jpeg, $sof);
def cut asbytesinit$jpeg[..$at + 3]; # mid headertry {
pdf.loadImage("Logo", $cut);
} catch (e) {
io.printf("%s\n%s\n", $e.kind, $e.message);
}