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

HEIC/HEIF image converter lambda #106

Merged
merged 4 commits into from
Apr 11, 2024

Conversation

CEBergin-Vivid
Copy link
Collaborator

Add the wfdm-image-converter lambda that will accept a HEIC/HEIF file and convert it to a jpg file via communication with the wfdm api.

…ndex initializer, add a call to the file index initializer to call the image conversion lambda for heic files
Copy link
Collaborator

@dhlevi dhlevi left a comment

Choose a reason for hiding this comment

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

Some cleanup we could do, but the basic changes look OK.

We could enhance the check for the heic file to check the binary directly vs just checking an extension, but that might not be needed day 1


// if a file has a heic or heif mimetype it needs to be converted by the image
// conversion lambda rather than processed
if (fileExtension.equals("HEIC") || fileExtension.equals("HEIF") ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It'd be nice if we had a better way to detect in case there was no extension...

You can also check for the file signature. Byte 5 to 8 should give you the constant "ftyp". The following 4 bytes would be the major brand, which I believe is one of "mif1", "heic" and "heix". For example, the first 12 bytes of a .heic image would be:

00 00 00 28 66 74 79 70 6d 69 66 31

which, after removing 0s and trim the result, literally decoded to ftypmif1.

wfdm-image-converter/index.js Outdated Show resolved Hide resolved
@dhlevi dhlevi merged commit ad64a64 into bcgov:main Apr 11, 2024
1 check passed
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.

2 participants