Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more image operations #515

Merged
merged 22 commits into from
Jul 3, 2019
Merged

Add more image operations #515

merged 22 commits into from
Jul 3, 2019

Conversation

j433866
Copy link
Member

@j433866 j433866 commented Mar 12, 2019

Adds 2 more image operations (Sharpen image and Convert image format).
Sadly Jimp doesn't support outputting as GIF so we're limited to JPEG, PNG, BMP and TIFF.

self.sendStatusMessage("Adding text to image...");

const fontsMap = {
"Roboto": await import(/* webpackMode: "eager" */ "../../web/static/fonts/bmfonts/Roboto72White.fnt"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use Promise.all here so we're not awaiting for each of these to load individually? Not sure whether webpack will be friends with that though...

Copy link
Member Author

Choose a reason for hiding this comment

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

Would something like this be better? Webpack seems to be happy with it.

const fontsMap = {};
const fonts = [
    import(/* webpackMode: "eager" */ "../../web/static/fonts/bmfonts/Roboto72White.fnt"),
    ...
];

await Promise.all(fonts)
    .then(fonts => {
        fontsMap.Roboto = fonts[0];
        ...
});

const fontImages = [
    import(/* webpackMode: "eager" */ "../../web/static/fonts/bmfonts/Roboto72White.png"),
    ...
];
await Promise.all(fontImages);

Also minor corrections to jsdocs in ImageManipulation
Change QR code ops to use ArrayBuffer.
Add new function to Utils to convert a string to arraybuffer.
Now resizes the text instead of the image
@n1474335
Copy link
Member

Ready to merge this. We just need to fix the conflict and I'm also getting a bug in the 'Add text to image' op:

jimp.js:34740 Uncaught (in promise) Error: HTTP Status 404 for url http://localhost:8080/assets/images/Roboto72White.png
    at XMLHttpRequest.eval (jimp.js:34740)

@n1474335 n1474335 merged commit bed6629 into gchq:master Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants