diff --git a/package.json b/package.json index f1a49c6..51ce3da 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "dependencies": { "electron-store": "^8.0.1", "fs-extra": "^10.0.0", + "gifsicle": "^5.3.0", "junk": "3.1.0", "mime-types": "^2.1.34", "mozjpeg": "^7.0.0", diff --git a/src/main/image-compressor.js b/src/main/image-compressor.js index 8deaeac..7e395b3 100644 --- a/src/main/image-compressor.js +++ b/src/main/image-compressor.js @@ -3,6 +3,7 @@ const { ensureDirSync, readFile, writeFile, readdir } = require('fs-extra') const { execFile } = require('child_process') const mozjpeg = require('mozjpeg') const pngquant = require('pngquant-bin') +const gifsicle = require('gifsicle') const svg = require('svgo') const junk = require('junk') const mime = require('mime-types') @@ -18,6 +19,7 @@ const MIME_TYPE_ENUM = { jpg: 'image/jpeg', png: 'image/png', svg: 'image/svg+xml', + gif: 'image/gif', folder: '' } @@ -152,6 +154,23 @@ class ImageOptimizer { break } + case MIME_TYPE_ENUM.gif: { + execFile(gifsicle, ['-o', output, file.path], err => { + if (err) { + console.log(err) + reject(err) + } + + const compressedSize = getFileSize(output) + context.webContents.send( + 'file-complete', + this.#formatOutputData(file, originalSize, compressedSize) + ) + resolve() + }) + break + } + case MIME_TYPE_ENUM.svg: { readFile(file.path, (err, buffer) => { if (err) { diff --git a/src/main/menu.js b/src/main/menu.js index bfade96..b09770b 100644 --- a/src/main/menu.js +++ b/src/main/menu.js @@ -99,7 +99,7 @@ module.exports = context => { V8: ${process.versions.v8} OS: ${os.type()} ${os.arch()} ${os.release()} - ©2019-${year} Anton Reshetov + ©2021-${year} Anton Reshetov ` }) } diff --git a/src/renderer/components/AppDragArea.vue b/src/renderer/components/AppDragArea.vue index 46186f4..456279b 100644 --- a/src/renderer/components/AppDragArea.vue +++ b/src/renderer/components/AppDragArea.vue @@ -8,7 +8,7 @@

Drag files or folder here

-

support only JPG, PNG and SVG

+

support only JPG, PNG, GIF and SVG

diff --git a/yarn.lock b/yarn.lock index 6ce2f89..6777360 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5027,6 +5027,15 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +gifsicle@5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/gifsicle/-/gifsicle-5.3.0.tgz#499713c6f1e89ebbc3630da3a74fdb4697913b4e" + integrity sha512-FJTpgdj1Ow/FITB7SVza5HlzXa+/lqEY0tHQazAJbuAdvyJtkH4wIdsR2K414oaTwRXHFLLF+tYbipj+OpYg+Q== + dependencies: + bin-build "^3.0.0" + bin-wrapper "^4.0.0" + execa "^5.0.0" + git-clone@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/git-clone/-/git-clone-0.1.0.tgz#0d76163778093aef7f1c30238f2a9ef3f07a2eb9"