Skip to content

Commit 7da9856

Browse files
committed
chore: merge branch 'master' of github.com:antonreshetov/image-optimize
2 parents 83d81d4 + e697da3 commit 7da9856

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"dependencies": {
5151
"electron-store": "^8.0.1",
5252
"fs-extra": "^10.0.0",
53+
"gifsicle": "^5.3.0",
5354
"junk": "3.1.0",
5455
"mime-types": "^2.1.34",
5556
"mozjpeg": "^7.0.0",

src/main/image-compressor.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { ensureDirSync, readFile, writeFile, readdir } = require('fs-extra')
33
const { execFile } = require('child_process')
44
const mozjpeg = require('mozjpeg')
55
const pngquant = require('pngquant-bin')
6+
const gifsicle = require('gifsicle')
67
const svg = require('svgo')
78
const junk = require('junk')
89
const mime = require('mime-types')
@@ -18,6 +19,7 @@ const MIME_TYPE_ENUM = {
1819
jpg: 'image/jpeg',
1920
png: 'image/png',
2021
svg: 'image/svg+xml',
22+
gif: 'image/gif',
2123
folder: ''
2224
}
2325

@@ -152,6 +154,23 @@ class ImageOptimizer {
152154
break
153155
}
154156

157+
case MIME_TYPE_ENUM.gif: {
158+
execFile(gifsicle, ['-o', output, file.path], err => {
159+
if (err) {
160+
console.log(err)
161+
reject(err)
162+
}
163+
164+
const compressedSize = getFileSize(output)
165+
context.webContents.send(
166+
'file-complete',
167+
this.#formatOutputData(file, originalSize, compressedSize)
168+
)
169+
resolve()
170+
})
171+
break
172+
}
173+
155174
case MIME_TYPE_ENUM.svg: {
156175
readFile(file.path, (err, buffer) => {
157176
if (err) {

src/renderer/components/AppDragArea.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="hero">
99
<AppLogo />
1010
<h2>Drag files or folder here</h2>
11-
<p>support only JPG, PNG and SVG</p>
11+
<p>support only JPG, PNG, GIF and SVG</p>
1212
</div>
1313
</div>
1414
</template>

yarn.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5027,6 +5027,15 @@ getpass@^0.1.1:
50275027
dependencies:
50285028
assert-plus "^1.0.0"
50295029

5030+
gifsicle@5.3.0:
5031+
version "5.3.0"
5032+
resolved "https://registry.yarnpkg.com/gifsicle/-/gifsicle-5.3.0.tgz#499713c6f1e89ebbc3630da3a74fdb4697913b4e"
5033+
integrity sha512-FJTpgdj1Ow/FITB7SVza5HlzXa+/lqEY0tHQazAJbuAdvyJtkH4wIdsR2K414oaTwRXHFLLF+tYbipj+OpYg+Q==
5034+
dependencies:
5035+
bin-build "^3.0.0"
5036+
bin-wrapper "^4.0.0"
5037+
execa "^5.0.0"
5038+
50305039
git-clone@^0.1.0:
50315040
version "0.1.0"
50325041
resolved "https://registry.yarnpkg.com/git-clone/-/git-clone-0.1.0.tgz#0d76163778093aef7f1c30238f2a9ef3f07a2eb9"

0 commit comments

Comments
 (0)