-
Notifications
You must be signed in to change notification settings - Fork 9
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
Replace sharp with jimp module #191
Conversation
- removes libvips dependency - simplifies installation process - should work on Node 9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How big is the performance difference between sharp and jimp?
@@ -66,8 +66,8 @@ module.exports = function(gulp, config) { | |||
fileClone.path = path.join(name.dir, name.name + '-' + size + name.ext) | |||
fileClone.imageTransform = { | |||
width: size, | |||
height: file.imageData.aspectRatio ? Math.ceil(size/file.imageData.aspectRatio) : null, | |||
options: file.imageData.options || {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe print some warning if user uses options that it's not working anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
lib/tasks/images.js
Outdated
.resize(file.imageTransform.width, file.imageTransform.height) | ||
.quality(image.quality) | ||
.getBuffer(jimp.AUTO, function(err, buffer) { | ||
if(err) console.error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was so in sharp version as well, but: Shouldn't we pass the error up in the callback? Not just silently dismiss it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the question - is a broken image a fatal fail or just a inconvience?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the image is then missing it's a fail.
.read(file.contents) | ||
.then(function(image) { | ||
image | ||
.resize(file.imageTransform.width, file.imageTransform.height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sharp's resize does crop. But JIMP just resizes it no matter what.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that it does scale up but sharp doesn't? Or how does the cropping work in sharp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. If both height and width is specified it resized it (keeping aspect ratio) and then cropped it (to specified dimension). JIMP on the other hand resizes it but does not keep aspect ratio, which leads to distortion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand. Okay, I'll add the behavior.
lib/tasks/images.js
Outdated
.then(function(image) { | ||
image | ||
.resize(file.imageTransform.width, file.imageTransform.height) | ||
.quality(image.quality) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand it will fail if undefined (source).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default is set at 90 few lines above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but was undefined anyway, thx for the sharp eye!)
Closing this for now. More in the #187 |
Todos
Opinions? Can you please test it if it works for you?
Thanks ❤️
Fixes #187, closes #190, see #180