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

Is it possible to use magickload? #2852

Closed
0x6A75616E opened this issue Aug 20, 2021 · 4 comments
Closed

Is it possible to use magickload? #2852

0x6A75616E opened this issue Aug 20, 2021 · 4 comments
Labels

Comments

@0x6A75616E
Copy link

I'm trying to convert RAW images to JPG. I've got vips compiled with magick support, and the following cli command works:

vips magickload /test-photos/Nikon/RAW_NIKON_D3200.NEF /test-photos/Nikon/RAW_NIKON_D3200.JPG

Now, when I try the same thing with Sharp, I get a really low resolution JPG as the output.

const sharp = require('sharp');
var fs = require('fs');

const filename = `/test-photos/Nikon/RAW_NIKON_D3200.NEF`
var readStream = fs.createReadStream(filename);


(() => {

    var writeStream = fs.createWriteStream(`${filename}.jpg`);

    writeStream.on('finish', () => {
        console.log("DONE")
    })

    
    const conv = sharp({
        failOnError: false
    })

    conv
        .jpeg({
            quality: 100,
            force: true
        })

    conv.pipe(writeStream)

    readStream.pipe(conv)

})()

I suspect what's happening is that the raw input has an embedded jpg thumbnail, and that's what's being converted here. Is there a way for me to specify that I want to use the full image data as input?

@lovell
Copy link
Owner

lovell commented Aug 20, 2021

I think Nikon RAW files masquerade as TIFF files. Given you're building your own libvips, try compiling it without libtiff support via ./configure --without-tiff

@0x6A75616E
Copy link
Author

Thanks @lovell. That'd most likely work, but wouldn't that leave me with no tiff support overall? That's something I still use.

Seems like the magickload command would work well. I was only wondering if it had been implemented. If it hasn't already, I may be able to put together a PR.

@lovell
Copy link
Owner

lovell commented Aug 20, 2021

sharp currently relies on libvips to determine the relevant loader for a given input and I'm unsure if the added complexity (error handling, testing etc.) of code in sharp to specify the loader is worth it.

Given you're building your own libvips, perhaps you could patch one/both of the relative priority values?

https://github.com/libvips/libvips/blob/97f5417aaa16c0eda19d98816b823bc92ebc93b3/libvips/foreign/tiffload.c#L182
https://github.com/libvips/libvips/blob/97f5417aaa16c0eda19d98816b823bc92ebc93b3/libvips/foreign/magick7load.c#L356

@lovell
Copy link
Owner

lovell commented Sep 23, 2021

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

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

No branches or pull requests

2 participants