-
Notifications
You must be signed in to change notification settings - Fork 2k
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
@uppy/thumbnail-generator: don't enlarge already small thumbnails #4406
base: main
Are you sure you want to change the base?
Conversation
@@ -161,6 +161,9 @@ export default class ThumbnailGenerator extends UIPlugin { | |||
|
|||
return Promise.all([onload, orientationPromise]) | |||
.then(([image, orientation]) => { | |||
const originalImageDimensions = { width: image.width, height: image.height } | |||
this.uppy.setFileMeta(file.id, { dimensions: originalImageDimensions }) |
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.
isn't this being stored somewhere else? is thumbnail-generator the right place to add this metadata? (it doesn't have anything to do with thumbnails I think?)
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.
What do you mean, stored somewhere else? Already, you mean? Not that I know of.
No, it’s not the right place, ideally we have a separate exif plugin that does this. But:
- It’s available “for free” here, we already read the original image to memory, so I thought why not store useful data (some people have asked for it).
- Alex asks the preview to behave differently, according to it’s size — if the image is smaller than container, like a tiny emoji, we have a white background for it, for instance. Ideally we need to know the image dimensions in CSS. So this would help here.
I also understand it doesn't feel “correct” to add this here, but since I was in this territory, decided to experiment and gather feedback.
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.
What do you mean, stored somewhere else? Already, you mean? Not that I know of.
I just thought that width and height is very common metadata for an image so I thought we are already setting it somewhere else in the code.
- It’s available “for free” here, we already read the original image to memory, so I thought why not store useful data (some people have asked for it).
Yea, but then if someone needs the dimensions, but they don't want the thumbnail plugin, then they won't get it. and if we later add this to core, then there will be two different width/height metadata, which would be confusing.
2. Alex asks the preview to behave differently, according to it’s size — if the image is smaller than container, like a tiny emoji, we have a white background for it, for instance. Ideally we need to know the image dimensions in CSS. So this would help here.
Shouldn't it instead be stored inside plugin state then, because it's a thumbnail plugin specific state?
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.
Shouldn't it instead be stored inside plugin state then, because it's a thumbnail plugin specific state?
👍
Before:
After: