-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
feat: add safer nativeImage.createFromBitmap(), which does not decode PNG/JPEG #17337
Conversation
8c4f6bb
to
de3e18f
Compare
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.
IMO we should deprecate createFromBuffer
, and replace it with createFromBitmap
(or maybe createFromRGBA
), createFromPNG
and createFromJPEG
. Just guessing at the image format isn't really a sane way to do it.
3e03037
to
df45afd
Compare
@nornagon I was just thinking about doing that. I agree that having separate |
I'm thinking we should probably have some kind of "guess what this is" method. I can see it being handy when you think a file is an image but don't know what format it is. |
I think that falls outside the scope of Electron. See e.g. http://www.darwinsys.com/file/ |
@nornagon At least pointing people to that / an npm module for file type detection would be enough. I just don't want to say "figure it out have fun" 👍 |
db6d05a
to
ad99925
Compare
It's not guessing, it's detecting, and I think it should stay. It's a nice convenience. I agree there should also be explicit methods for JPEG and PNG. |
My |
ad99925
to
019fcf8
Compare
Release Notes Persisted
|
Description of Change
Required to safely serialize/deserialize
NativeImage
instances to be sent over IPC in #17200/cc @nornagon
Checklist
npm test
passesRelease Notes
Notes: Added safer
nativeImage.createFromBitmap()
, which does not decode PNG/JPEG.