Skip to content

Commit d258196

Browse files
author
Jean-Claude Jung
committed
changed mimetype to list of image file extension
1 parent df56a87 commit d258196

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

Image Shrinker.alfredworkflow

33 Bytes
Binary file not shown.

src/filecheck.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/usr/bin/python3
22

3-
import mimetypes
43
import sys
54
from pathlib import Path
65

6+
WHITELIST_EXT = [
7+
'png',
8+
'jpeg',
9+
'jpg'
10+
'gif',
11+
'tiff',
12+
'bmp',
13+
'psd',
14+
'heic'
15+
]
16+
717
image_files = []
818
for f in sys.argv[1::]:
9-
mt, n = mimetypes.guess_type(f)
10-
ext = Path(f).suffix
11-
if ext.lower() == '.heic' or (mt != None and "image" in mt):
19+
ext = Path(f).suffix.replace('.', '').lower()
20+
if ext in WHITELIST_EXT:
1221
image_files.append(f)
1322

1423
files = "\t".join(image_files)

src/info.plist

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@
330330
<string>public.heic</string>
331331
<string>public.jpeg</string>
332332
<string>public.png</string>
333+
<string>public.svg-image</string>
333334
<string>public.tiff</string>
334335
</array>
335336
<key>name</key>
@@ -465,6 +466,26 @@ python3 ./filecheck.py $argv</string>
465466
<key>version</key>
466467
<integer>1</integer>
467468
</dict>
469+
<dict>
470+
<key>config</key>
471+
<dict>
472+
<key>argument</key>
473+
<string>{var:fpath}</string>
474+
<key>passthroughargument</key>
475+
<false/>
476+
<key>variables</key>
477+
<dict>
478+
<key>size</key>
479+
<string>{query}</string>
480+
</dict>
481+
</dict>
482+
<key>type</key>
483+
<string>alfred.workflow.utility.argument</string>
484+
<key>uid</key>
485+
<string>8E04C74A-AFA3-45A5-AB78-FBD21C7699C8</string>
486+
<key>version</key>
487+
<integer>1</integer>
488+
</dict>
468489
<dict>
469490
<key>config</key>
470491
<dict>
@@ -486,26 +507,6 @@ python3 ./filecheck.py $argv</string>
486507
<key>version</key>
487508
<integer>1</integer>
488509
</dict>
489-
<dict>
490-
<key>config</key>
491-
<dict>
492-
<key>argument</key>
493-
<string>{var:fpath}</string>
494-
<key>passthroughargument</key>
495-
<false/>
496-
<key>variables</key>
497-
<dict>
498-
<key>size</key>
499-
<string>{query}</string>
500-
</dict>
501-
</dict>
502-
<key>type</key>
503-
<string>alfred.workflow.utility.argument</string>
504-
<key>uid</key>
505-
<string>8E04C74A-AFA3-45A5-AB78-FBD21C7699C8</string>
506-
<key>version</key>
507-
<integer>1</integer>
508-
</dict>
509510
<dict>
510511
<key>config</key>
511512
<dict>
@@ -930,7 +931,7 @@ Click on `Configure Workflow` to:
930931
<key>variablesdontexport</key>
931932
<array/>
932933
<key>version</key>
933-
<string>1.4</string>
934+
<string>1.4.1</string>
934935
<key>webaddress</key>
935936
<string>https://github.com/Acidham/alfred-image-shrinker</string>
936937
</dict>

0 commit comments

Comments
 (0)