Skip to content

Update JIMP#2171

Open
C85297 wants to merge 16 commits intogchq:masterfrom
C85297:update-jimp
Open

Update JIMP#2171
C85297 wants to merge 16 commits intogchq:masterfrom
C85297:update-jimp

Conversation

@C85297
Copy link
Member

@C85297 C85297 commented Feb 3, 2026

No description provided.

@C85297 C85297 self-assigned this Feb 3, 2026
@C85297 C85297 added the dependencies Pull requests that update a dependency file label Feb 3, 2026
"maxBOF": 0
}],
"no-whitespace-before-property": "error",
"operator-linebreak": ["error", "after"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not convinced this is the right fix.

The "operator goes at the end of the line, even for ternary operators" convention has been used throughout the rest of the codebase.

Probably therefore better to fix the "errors" this change has thrown up rather than changing/removing the convention (though, presumably like you, I'm not convinced it's the convention I'd have selected at the outset).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right - laziness on my part since I couldn't work out how to change my editors behaviour :D I'll sort this out once I get the tests working

@GCHQDeveloper581
Copy link
Contributor

I think your error may be related to what I was looking at in https://github.com/GCHQDeveloper581/CyberChef/tree/fix-issue-XXXX

@GCHQDeveloper581
Copy link
Contributor

Actually looking harder at the error returned, I think it's another issue I've (also previously) encountered with the root cause being that some Operations return a Value and others return a Promise. In the normal browser this seems to work out OK but when running under node it creates an issue.

@C85297
Copy link
Member Author

C85297 commented Feb 5, 2026

So I worked out the error was this:

    at Object.p [as next] (http://localhost:8000/modules/Image.js:2:1023389)
    at S (http://localhost:8000/modules/Image.js:2:1024030)
    at http://localhost:8000/modules/Image.js:2:1024950
    at transpile (http://localhost:8000/modules/Image.js:2:1024969)
    at convertXML (http://localhost:8000/modules/Image.js:2:1025103)
    at loadBitmapFontData (http://localhost:8000/modules/Image.js:2:1026062)
    at async loadFont (http://localhost:8000/modules/Image.js:2:1027310))" (1ms)

Which was caused by Jimp attempting to load the font file as XML (which it wasn't). It seems Jimp used to support BMFont text files, but now only supports BMFont XML files.

I created a simple program using bmfont_rs to convert the files to XML:

fn main() -> bmfont_rs::Result<()> {
    for fnt_in_fname in std::env::args().skip(1) {
        let fnt_in_path = std::path::PathBuf::from(&fnt_in_fname);
        let fnt = bmfont_rs::text::from_bytes(&std::fs::read(&fnt_in_path)?)?;
        let fnt_out_path = fnt_in_path
            .with_extension("")
            .with_added_extension("fnt")
            .with_added_extension("xml");
        std::fs::write(&fnt_out_path, bmfont_rs::xml::to_vec(&fnt)?)?;
        println!("{:?} -> {:?}", fnt_in_path, fnt_out_path);
    }
    Ok(())
}

As the font files had incorrect negative spacing values, I had to remove the signs on these and re-add them on the outputted XML files.

@C85297
Copy link
Member Author

C85297 commented Feb 5, 2026

The output of Add Text To Image has slightly changed.

Previously:
image

Now:
image

Although in this case it looks correct testing on a larger image shows the alignment is broken:

Previously:
image

Now:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants