olxgroup-oss / libvips-rust-bindings

Rust bindings for libvips
MIT License
95 stars 41 forks source link

profile_load: unable to load profile when using thumbnail_image_with_opts #12

Closed jgould22 closed 3 years ago

jgould22 commented 3 years ago

Hi @augustocdias I am unsure if this is related https://github.com/olxgroup-oss/libvips-rust-bindings/issues/11 but I am encountering an issue when trying to us thumbnail_image_with_opts. When I attempt to thumbnail the image I receive the following error

[src/image_utils.rs:158] &error = ThumbnailImageError
[src/image_utils.rs:159] vips_app.error_buffer().unwrap() = "vips__file_read: error reading from file \"\"\nprofile_load: unable to load profile \"\"\n"

Here is a gist of some code and a sample image I found that produces the error https://gist.github.com/jgould22/8e3a09497e5821d9dcd0575d9c830be0

As far as I can tell I am using libvips 8.10.2 installed with

git clone --depth 1 --branch v8.10.2 https://github.com/libvips/libvips.git && \
        cd libvips && \
        ./autogen.sh && \
        make -j 15 && \
        make install

and the bindings are

libvips = "1.4.2"

Thanks for the bindings and any help with the above error is greatly appreciated!

augustocdias commented 3 years ago

There's an issue with the bindings that it generates with empty profiles. the Default implementation for each of this structs uses defaults from the library only when the introspection library provides so, otherwise it uses Rust's default for the type.

This is the case for the profile field. Although it has an internal default value in the libvips, the introspection doesn't say which value is that and the bindings set it to an empty string.

You could solve this by setting the profile field in the opts to "sRGB" for example.

jgould22 commented 3 years ago

Thank you

Adding the following has fixed my issue, thank you for the help

import_profile:String::from("sRGB"),
export_profile:String::from("sRGB"),