Extracts image files embedded within an .accountpicture-ms
file.
NB: I made a "web converter" just for fun as well: https://xan105.github.io/node-accountpicture-ms-extractor/
Located in
%appdata%/Microsoft/Windows/AccountPictures
(Windows 8, 10)%appdata%/Microsoft/Windows/Account Pictures
(Windows 11)
There are either 2 PNG or JPEG image files:
- Lowres: 96x96
- Highres: usually 448x448 (upscaled if necessary).
From my experience: Microsoft seems to be changing the format, resolution (only for highres), compression ratio (If JPEG), etc... used for the embedded images over time.
As of this writing they are using JPEG: 96x96 and 448x448. But not that long ago they were using PNG and before that JPEG highres was the original resolution of the file you used for your account's picture.
NB:
- For JPEG both files have a JPEG and JFIF header.
- There can be more than one
.accountpicture-ms
file in the mentionned folders. - The extension
.accountpicture-ms
is hidden by the explorer even when set to display file extension. - The current used
{SourceId}.accountpicture-ms
can be determined via the registry keyHKCU/Software/Microsoft/Windows/CurrentVersion/AccountPicture/SourceId
import extract from "accountpicture-ms-extractor";
import { join } from "node:path";
const sourceID = "37a1276dd7295e1a";
const dirPath = join(process.env.APPDATA,"Microsoft/Windows/AccountPictures");
const filePath = join(dirPath,`${sourceID}.accountpicture-ms`);
const { highres, lowres } = await extract(filePath);
//save to file
import { writeFile } from "node:fs/promises";
await writeFile(`./${sourceID}.${highres.format}`, highres.buffer);
//data url
const base64 = highres.base64();
console.log(base64);
// "data:image/jpeg;charset=utf-8;base64,....."
I'm actually using this in xan105/Achievement Watcher
to display user's profile picture in the app (Electron).
Using the .base64()
method you can read and display the picture without any prior extraction to disk.
npm install accountpicture-ms-extractor
Previous version(s) are CommonJS (CJS) with an ESM wrapper.
Extracts image files embedded within an .accountpicture-ms
file.
Promise returns the following object:
{
lowres : {
buffer: Buffer, //file as a Buffer
format: string, //file format "png" or "jpeg"
base64(): string, //return file as a base64 encoded string
blob(): Blob //return file as a Blob
},
highres: {
buffer: Buffer,
format: string,
base64(): string,
blob(): Blob
}
}