Skip to content

Commit

Permalink
Support for png images
Browse files Browse the repository at this point in the history
  • Loading branch information
styts committed Oct 26, 2017
1 parent 35d35d8 commit 585ea7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ prompt.dup = (file, options) =>
open.images = (options) => open({
filters: [{
name: t('dialog.filter.images'),
extensions: ['jpg', 'jpeg']
extensions: ['jpg', 'jpeg', 'png']
}],
properties: ['openFile', 'multiSelections'],
...options
Expand Down
7 changes: 5 additions & 2 deletions src/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,9 @@ function resize(image, size) {
}

function isValidImage(file) {
return file.type === 'image/jpeg'
return ['image/jpeg', 'image/png'].includes(file.type)
}


function NI(src) {
return new Promise((resolve) => {
resolve(typeof src === 'string' ?
Expand All @@ -185,6 +184,10 @@ function magic(b) {
if (b[0] === 0xFF && b[1] === 0xD8 && b[2] === 0xFF) {
return 'image/jpeg'
}
if (b.slice(0, 8).compare(
Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])) === 0) {
return 'image/png'
}
}

module.exports = {
Expand Down

0 comments on commit 585ea7f

Please sign in to comment.