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

Issue with thumbnail_with_opts #42

Open
GamerBene19 opened this issue Oct 18, 2023 · 2 comments
Open

Issue with thumbnail_with_opts #42

GamerBene19 opened this issue Oct 18, 2023 · 2 comments

Comments

@GamerBene19
Copy link

GamerBene19 commented Oct 18, 2023

I'm trying to resize an image based on height and width.
If I use thumbnail (only using width) it works as intended, using thumbnail_with_opts it does not.
Note that I have moved the App into the function to be able to access the error buffer.

fn manipulate_image(path: &str, height: i32, width: i32, quality: u32) -> Result<(), ()> {
    let libvips = VipsApp::new("app", true).expect("Could not start libvips");
    libvips.concurrency_set(2);

    // TODO: Error handling
    let thumb_opts = ops::ThumbnailOptions {
        height: height,
        ..ops::ThumbnailOptions::default()
    };
    log::info!("{}", path);
    // This works
    // let image = ops::thumbnail(&path, width).unwrap();
    // This doesn't
    let image: VipsImage = match ops::thumbnail_with_opts(path, width, &thumb_opts) {
        Err(err) => {
            log::error!("{}", err);
            log::error!("{}", libvips.error_buffer().unwrap());
            return Err(());
        }
        Ok(img) => img,
    };

    image.image_write_to_file("uploads/temp.jpg").unwrap();
    return Ok(());
}

I do get the following error (the path from above does exist)

vips error: ThumbnailError. Check error buffer for more details
vips__file_read: error reading from file ""
    profile_load: unable to load profile ""
    vips__file_read: error reading from file ""
    profile_load: unable to load profile ""
    
vips_threadset_free: peak of 0 threads
memory: high-water mark 1.35 MB
error buffer: vips__file_read: error reading from file ""
profile_load: unable to load profile ""
vips__file_read: error reading from file ""
profile_load: unable to load profile ""

Am I doing something wrong? If so please tell me what the correct way is.

@psytraxx
Copy link

i experienced a similar issue
my fix was to add

import_profile: "sRGB".into(),
export_profile: "sRGB".into(),

to &ops::ThumbnailImageOptions

@GamerBene19 GamerBene19 changed the title Issue with ` Issue with thumbnail_with_opts Oct 18, 2023
@GamerBene19
Copy link
Author

i experienced a similar issue my fix was to add

import_profile: "sRGB".into(), export_profile: "sRGB".into(),

to &ops::ThumbnailImageOptions

That worked. Thank you very much!

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

No branches or pull requests

2 participants