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 bitmap support [WIP] #483

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

coelhosandro
Copy link

@coelhosandro coelhosandro commented Jun 6, 2023

Issue #, if available:

We have stored in S3 images in bitmap format. Such files are not supported by the image handler. This patch aims to convert those files as PNG before processing the request

Description of changes:

Added a class to read/identify Bitmaps files using Jimp and convert those into PNG (which is supported by Sharp)

Checklist

  • 👋 I have added unit tests for all code changes.
  • 👋 I have run the unit tests, and all unit tests have passed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@coelhosandro
Copy link
Author

Hi @dougtoppin / @evanwieren / @hyandell , @fisenkodv

May I ask you guys to review this one?

Thank you in advance

Comment on lines +26 to +33
imageSignature === "89504E47" ||
imageSignature === "FFD8FFDB" ||
imageSignature === "FFD8FFE0" ||
imageSignature === "FFD8FFEE" ||
imageSignature === "FFD8FFE1" ||
imageSignature === "52494646" ||
imageSignature === "49492A00" ||
imageSignature === "4D4D002A"
Copy link
Contributor

Choose a reason for hiding this comment

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

These constants are already defined, in the image-request.ts, why don't check only 424d here?

import Jimp from "jimp";
import { ImageHandlerError, StatusCodes } from "./lib";

export class BitmapRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class mostly converter from BMP to PNG, IMO ImageConverter is more appropriate name, or you can get rid of it at all and move into image-request.ts, like

private convert(imageBuffer: Buffer): Promise<Buffer> {
  // if image is BMP return converted into PNG buffer
  // else do nothing and return `imageBuffer`
}

@@ -15,7 +15,8 @@
"color": "4.2.3",
"color-name": "1.1.4",
"sharp": "^0.31.3",
"aws-sdk": "^2.1356.0"
"aws-sdk": "^2.1356.0",
"jimp": "^0.22.8"
Copy link
Contributor

Choose a reason for hiding this comment

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

This package brings a lot of dependencies, for BMP it uses https://github.com/shaozilee/bmp-js, please refer to https://github.com/jimp-dev/jimp/blob/245f1cf60e0167d4d733ef90e638428d065856b2/packages/type-bmp/package.json#L25 I think you could use bmp-js instead.

read: jest.fn()
}));

describe('BitmapRequest', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

From my point of view, you should not consider it as a Request. Please create appropriate tests in

  • source/image-handler/test/image-handler
  • source/image-handler/test/image-request/infer-image-type.spec.ts

@coelhosandro
Copy link
Author

@ fisenkodv thanks for review that. Gonna adjust everything and let you know 👍

@coelhosandro coelhosandro marked this pull request as draft October 2, 2023 11:14
@coelhosandro coelhosandro changed the title Add bitmap support Add bitmap support [WIP] Oct 2, 2023
@dougtoppin
Copy link
Contributor

@coelhosandro Is this something that you are still interested in pursuing?
If so, please do the following

  • update to v6.2.4
  • address the previously entered comments
  • add the requested unit tests
  • submit the PR

@deurk
Copy link

deurk commented Jul 19, 2024

Any way to get this finished?

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.

5 participants