jimp icon indicating copy to clipboard operation
jimp copied to clipboard

"Could not find MIME for Buffer <null>" on loadFont with fnt file

Open KabanFriends opened this issue 4 years ago • 4 comments

Expected Behavior

Jimp.loadFont("path/to/fnt/file")

should load the font from a fnt file

Current Behavior

Using jimp.loadFont throws an error about MIME

Failure Information (for bugs)

Error:

Error: Could not find MIME for Buffer <null>
    at Jimp.parseBitmap (F:\WORKSPACE\image\node_modules\@jimp\core\dist\utils\image-bitmap.js:187:15)
    at Jimp.parseBitmap (F:\WORKSPACE\image\node_modules\@jimp\core\dist\index.js:431:32)
    at F:\WORKSPACE\image\node_modules\@jimp\core\dist\index.js:373:15
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:75:3)

I will provide other information if needed. the fnt file I used cannot be shared since it's generated out of a paid font.

KabanFriends avatar Jul 05 '21 09:07 KabanFriends

is there any solution about this problem?

PEPESICHE avatar Jul 21 '21 07:07 PEPESICHE

Is it a bitmap font? that's the only type of font jimp supports right now

hipstersmoothie avatar Feb 05 '23 01:02 hipstersmoothie

I came across this issue. it happened after I converted a file from a ttf format to a fnt format using Hiero and then uploaded it to Firebase storage. It works normally if the file exists locally with my code but once I tried using the uploaded file it gave this error. I uploaded both the fnt file and the png produced when I converted the ttf file.

I also tried downloading the file I uploaded again to test if it still works and it did work when I tested it locally.

Error: Could not find MIME for Buffer <null>
    at Jimp.parseBitmap (<project-directory>\@jimp\core\src\utils\image-bitmap.js:156:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  methodName: 'constructor'
}

Here is a zip file with the original ttf file and the files produced by Hiero. gt-walsheim-pro-bold-20.zip

AbanobNageh avatar Apr 08 '24 18:04 AbanobNageh

The issue still persists. No Error const font = await Jimp.loadFont(Jimp.FONT_SANS_128_WHITE);

Exact same error as the title. const font = await Jimp.loadFont( path.resolve( process.cwd(), "src", "assets", "cookie-regular.fnt" ) );

Edit (FIX):

  • When I converted the cookie-regular ttf font using this converter it used tga files.
  • Jimp doesn't really like the tga files, so I opened them in photoshop and converted them to pngs and saved them.
  • Plus, I edited the specifications in the ".fnt" file too so it points to the pngs instead of the tga
  • It just started working now so if anyone else is having the same issue follow the steps given above.

notcacti avatar Apr 20 '24 07:04 notcacti