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

feature request support BMP format as pointed in above #3509 (comment) #3843

Closed
tx0c opened this issue Nov 7, 2023 · 4 comments
Closed

feature request support BMP format as pointed in above #3509 (comment) #3843

tx0c opened this issue Nov 7, 2023 · 4 comments

Comments

@tx0c
Copy link

tx0c commented Nov 7, 2023

Feature request

What are you trying to achieve?

but it's same BMP format as pointed in above #3509 (comment)

so can I file a feature request for Windows BMP files? if the browser can show it no problem, why cannot sharp process it?

Originally posted by @tx0c in #3509 (comment)

const res = await fetch(https://github.com/Jeff-Tian/gatsby-js/26158879194071fb652efb0f9659edd6ab553d70/packages/gatsby-plugin-sharp/src/__tests__/images/metadata-error.png);
const image = sharp(await res.arrayBuffer(), { animated: false, failOn: "none" });
const metadata = await image.metadata();

// then outer try catch got ERROR: [Error: Input buffer contains unsupported image format]
and it seems also PC bitmap format:

$ wget 'https://github.com/Jeff-Tian/gatsby-js/26158879194071fb652efb0f9659edd6ab553d70/packages/gatsby-plugin-sharp/src/__tests__/images/metadata-error.png'
$ file ./tmp/c16b9dbe-9d9f-4893-9b8b-f22f2656b479.png
./tmp/c16b9dbe-9d9f-4893-9b8b-f22f2656b479.png: PC bitmap, Windows 3.x format, 1280 x 720 x 24, resolution 3780 x 3780 px/m, cbSize 2764854, bits offset 54

Please provide sample image(s) that help explain this feature


Hi, this looks like a Windows bitmap (BMP) file.

$ curl -s https://github.com/Jeff-Tian/gatsby-js/26158879194071fb652efb0f9659edd6ab553d70/packages/gatsby-plugin-sharp/src/__tests__/images/metadata-error.png | file -
/dev/stdin: PC bitmap, Windows 98/2000 and newer format, 1710 x 624 x 32, cbSize 4268298, bits offset 138

Originally posted by @lovell in #3509 (comment)

and https://camo.githubusercontent.com/fd352155596f7d714ee12230f59da7323b626c729ca94c5d4b934e379bf52fe0/68747470733a2f2f6173736574732e6d6174746572732e6e6577732f656d6265642f63313662396462652d396439662d343839332d396238622d6632326632363536623437392e706e67

@tx0c
Copy link
Author

tx0c commented Nov 7, 2023

in browser image1 showing no problem, and the convert from ImageMagick can process it, why not sharp ?

@lovell
Copy link
Owner

lovell commented Nov 7, 2023

Please see #543 #806 #3035 for possible methods of decoding BMP images.

@lovell lovell closed this as completed Nov 7, 2023
@tx0c
Copy link
Author

tx0c commented Nov 8, 2023

it's not complete, but if such a method like #3035 (comment) exists, why can't merge this logic as a helper into sharp?

make the sharp npm module as smooth as possible, support as many formats as possible

@lovell
Copy link
Owner

lovell commented Nov 8, 2023

Supporting as many formats as possible is not an aim of sharp, so it may be the wrong tool to solve your problem.

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

No branches or pull requests

2 participants