NAI Card Metadata

Tools

  • NAI card reader By No. 347972082
  • JSON tooltip userscript by No.348183782

    I wrote a shitty violentmonkey script to quickly look at the json of cards. It was more just a thing for me to relearn web stuff, and I think someone was working on something similar, so I dunno how useful it is. You hover over the card and press control to make the box of json appear. Then hover over the box and press shift to make it go away. You can also double click the box to copy the json.

Getting metadata

exiftool -naidata image.png | cut -b 35- | base64 -d

Python

1
2
3
4
5
def get_naidata(image_filename):
    data = open(image_filename, "rb").read()
    loc = data.find(b"naidata")
    length = int.from_bytes(data[loc-8:loc-4], "big")
    return data[loc+8:loc+length]

Javascript

function bytesToInt(buffer) {
    var value = 0;
    for (var i = 0; i < buffer.length; i++) {
        value = (value << 8) + buffer[i];
    }
    return value;
};

const NAIDATA = new Uint8Array([ 110, 97, 105, 100, 97, 116, 97 ]);
function isMatch(element, index, array) {
  for (var i=0; i<7; i++) {
    if (array[index+i] != NAIDATA[i]) return false;
  }
  return true;
}

function get_naidata(array) {
    /* array : Uint8Array from new Uint8Array( FileReader.readAsArrayBuffer() ) */
    var loc = array.findIndex(isMatch);
    var length = bytesToInt(array.slice(loc-8, loc-4));
    var result = array.slice(loc+8, loc+length);
    return new TextDecoder().decode(result);
}

Attaching metadata

naidata.conf

1
2
3
4
5
6
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::PNG::TextualData' => {
        naidata => { }
    }
);
1;
exiftool -config naidata.conf -naidata="BASE64" image.png
Edit Report
Pub: 17 Aug 2021 14:55 UTC
Edit: 19 Aug 2021 04:53 UTC
Views: 74