-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
A hook to access sharp instance for extra processing (crop, maintain EXIF, etc) #52
Comments
I'd love to be able to have a hook to access EXIF data. |
I'd like to see this too – I want to get hold of the image's dominant colour from the Sharp stats: https://sharp.pixelplumbing.com/api-input#stats |
|
I already commented on the other issue report, but want to repeat the request here: Yes, keeping image metadata like EXIF, XMP, and IPTC and also the ICC colour profile are critical for me as well. I would be super thankful if somebody could implement the hooks to activate/access the "withMetadata" functionality that is already in sharp: https://sharp.pixelplumbing.com/api-output#withmetadata Thanks a ton! Tom |
Would it be bad to do something as naïve as adding a if(typeof this.options.sharpHook === "function") {
sharpInstance = this.options.sharpHook(sharpInstance);
} It's not foolproof by any means. It would allow the dev to completely override what 11ty-img is doing: one could EDIT Putting that code a bit higher does feel better. After the sharp instance clone on line 481, but before the current resize/rotate code means that any resizing the user does in the hook is overwritten by the plugin options. While that means ignoring explicit calls to |
I can't comment on the "would it be bad" part ;-) My current workaround is setting the default for "withMetadata" to "true" in the sharp/lib/constructor.js (line 261). But yeah, like I wrote on the other thread, IMO this is mission critical for any application of eleventy where the image IS the product. Thanks to everybody looking into this! |
@ScreenDream Feel free to use my fork - though I won't guarantee this will always be around, though for the moment I'll be using it until there's a solution in the main repo here (bit easier than re-writing my code to use Sharp directly). Sounds like you're doing everything at build time though and don't need access to a proper package so your solution may be stable enough. Here's how you'd use a GitHub url in your |
First of all, thanks for this great plugin - it is a really valuable tool when working with image content! As this PR is closed: is the Feature (a hook exposing Edit: ok now i get it, closed PR != rejected feature. However as i have to work with a fork of |
I was just wondering about this. I wrote up an experiment here where I used Sharp to essentially get the background colour of an image. I called Sharp directly to do this, which feels like a doubling of work (assuming the data I generated already exists somewhere). |
Shipping with v6.0.0-beta.1 await Image("./test/exif-sample-large.jpg", {
// Keep exif metadata
transform: (sharp) => {
sharp.keepExif();
}
}); This is a preprocessing step that runs before the Image runs orientation fix, resize, and format conversion (all of which still run afterwards) |
Is 6.0.0-beta.1 available already? And will that keep both Exif metadata and ICC profiles like "keepMetadata()" does with Sharp? We are working on a new website and my old hack no longer works... |
Not yet—finishing up some last issue triage before we release! Soon! |
Awesome! Thank you! ❤️❤️❤️ |
See https://twitter.com/ericvalois/status/1352203081304436738
The text was updated successfully, but these errors were encountered: