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

Some bitmaps fail in GoVips but work with Vips #300

Open
jhford-scout24 opened this issue Aug 4, 2022 · 2 comments
Open

Some bitmaps fail in GoVips but work with Vips #300

jhford-scout24 opened this issue Aug 4, 2022 · 2 comments

Comments

@jhford-scout24
Copy link

I am bringing our image scaling application up to date using govips v2. Thanks for the huge effort to bring the library up to date, it's great!

I have one small issue right now around Bitmap support. I believe that there's something in the bindings which has changed around Bitmap handling. Bitmaps generated in the OS/2 format do not load when they are loaded by govips, instead returning the error bmp: unsupported BMP image.

$ file ../testdata/koala.bmp*
../testdata/koala.bmp:  PC bitmap, Windows 98/2000 and newer format, 1024 x 768 x 24, cbSize 2359434, bits offset 138
../testdata/koala.bmp2: PC bitmap, OS/2 1.x format, 1024 x 768 x 24, cbSize 2359322, bits offset 26
../testdata/koala.bmp3: PC bitmap, Windows 3.x format, 1024 x 768 x 24, image size 2359296, resolution 2834 x 2834 px/m, cbSize 2359350, bits offset 54

These files are definitely loadable by the Vips CLI program for the installation that matches the one used by govips:

$ vips rot ../testdata/koala.bmp2 out.jpg d90
$ file out.jpg
out.jpg: JPEG image data, <snip> 768x1024 <snip>

I know this is an edge case, but I suspect it's because BMP handling is being done using the standard library? I haven't dug into it yet.

Here are the files in question. This picture was originally obtained through wikipedia I believe, and reencoded to these bitmap formats using ImageMagick Archive.zip

@jhford-scout24
Copy link
Author

jhford-scout24 commented Aug 4, 2022

Ah, I see that BMP files are handled in a special way by using the bmp go package which is known to not support all versions of BMP

foreign.go: vipsLoadFromBuffer is the relevant function.

I'm curious why this approach was taken?

jhford-scout24 pushed a commit to jhford-scout24/govips that referenced this issue Aug 4, 2022
The bitmap library used for this does not support the various bitmap
formats in the wild. This is also very confusing behaviour for a user of
the pre-v2 version of govips, which was able to handle all the various
bmp files

Closes davidbyttow#300
@cshum
Copy link
Contributor

cshum commented Aug 5, 2022

I also wonder why. If I need such conversion I could have call the function myself. Since this is advertised as a libvips binding, it should be as close to libvips as possible.

To make things worse, the recent changes seems to put yet another hacky layer on top of this: https://github.com/davidbyttow/govips/pull/299/files

I presume the Go BMP to PNG conversion was made for backward compatibility? I would much rather deprecate it though.

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 a pull request may close this issue.

2 participants