-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharia_extra_img.py
508 lines (453 loc) · 26 KB
/
aria_extra_img.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
import re
from PIL import Image, ImageFilter, ImageEnhance, ImageOps, ImageDraw
from ariautils.command_utils import Command
from ariautils import context_utils, io_utils
from ariautils.misc_utils import any_in_str
class ImgCmd(Command):
info = {
"title": "Image Management for Aria",
"repository": "https://github.com/SKaplanOfficial/Aria-Commands/Aria-Extras",
"documentation_link": "https://github.com/SKaplanOfficial/Aria/documentation/",
'id': "aria_extra_img",
"version": "1.0.0",
"description": """
This command offers various images management and manipulation functionalities supported by Aria's contextual awareness.
""",
"requirements": {
"aria_open": "1.0.0",
},
"extensions": {},
"purposes": [
"flip ./img.png horizontally", "rotate these images 90 deg clockwise", "resize this to 300x300", "make all of these grayscale"
],
"targets": [
"./img.png", "./folder_of_images", "these images", "this image", "this", "these"
],
"keywords": [
"aria", "command", "extra", "image", "contextual", "utility"
],
"example_usage": [
("increase the contrast of this", "Increase the contrast of the selected image by a factor of 2."),
("increase the contrast of these by a factor of 1.2", "Increase the contrast of the selected images by a factor of 1.2."),
("find the edges in this", "Run edge detection on the selected image."),
("add a circle mask to these", "Add a circular mask over the selected images, positioned at the center of each image."),
("brighten this", "Brighten the selected image by a factor of 2."),
("rotate this 90 degrees right", "Rotate the selected image 90 degrees clockwise."),
("flip this horizontally", "Flip the selected image across the y axis (from left to right)."),
("add a 30 pixel border to each of these", "Add a 30 pixel white border to each of the selected images."),
],
"help": [
"As of now, you must select items in Finder for any of the functions to work.",
],
"contact_details": {
"author": "Stephen Kaplan",
"email": "[email protected]",
"website": "http://skaplan.io",
},
"info_version": "0.9.0",
}
def execute(self, query, origin):
parts = query.split()
query_type = self.get_query_type(query, get_tuple = True)
if query_type[0] >= 5000:
# Operate on selected files in Finder
selected_items = context_utils.get_selected_items()
if selected_items != None:
for item in selected_items:
self.__operate_in_place(item, query_type[1]["func"], query_type[1]["args"])
# I/O
def __operate_in_place(self, path, operation, args):
img = Image.open(path)
img = operation(img, *args)
if img.mode == "RGBA" and (path.lower().endswith(".jpg") or path.lower().endswith(".jpeg")):
path = path.replace(".JPEG", ".png").replace(".JPG", ".png").replace(".jpeg", ".png").replace(".jpg", ".png")
img.save(path)
io_utils.sprint("Operation complete.")
# Flipping
def __flip_h(self, image, _args = []):
io_utils.sprint("Flipping horizontally...")
return image.transpose(Image.FLIP_LEFT_RIGHT)
def __flip_v(self, image, _args = []):
io_utils.sprint("Flipping vertically...")
return image.transpose(Image.FLIP_TOP_BOTTOM)
def __mirror(self, image, _args = []):
io_utils.sprint("Mirroring...")
return ImageOps.mirror(image)
# Rotation
def __rotate_clockwise(self, image, angle, _args = []):
io_utils.sprint("Rotating clockswise...")
return image.rotate(angle = -angle)
def __rotate_counterclockwise(self, image, counterclock_angle, _args = []):
io_utils.sprint("Rotating counterclockwise...")
return image.rotate(angle = counterclock_angle)
# Resizing
def __resize(self, image, new_width, new_height, _args = []):
io_utils.sprint("Resizing...")
return image.resize((new_width, new_height), Image.ANTIALIAS)
def __scale(self, image, scale_factor = 2, _args = []):
io_utils.sprint("Rescaling...")
return ImageOps.scale(image, scale_factor)
def __add_border(self, image, border_width, border_color = 255):
io_utils.sprint("Adding border...")
return ImageOps.expand(image, int(border_width), border_color)
# Enhancements
def __enhance_color(self, image, enhance_factor = 2, _args = []):
io_utils.sprint("Enhancing color...")
return ImageEnhance.Brightness(image).enhance(enhance_factor)
def __enhance_contrast(self, image, enhance_factor = 2, _args = []):
io_utils.sprint("Enhancing contrast...")
return ImageEnhance.Contrast(image).enhance(enhance_factor)
def __enhance_brightness(self, image, enhance_factor = 2, _args = []):
io_utils.sprint("Enhancing brightness...")
return ImageEnhance.Brightness(image).enhance(enhance_factor)
def __enhance_sharpness(self, image, enhance_factor = 2, _args = []):
io_utils.sprint("Enhancing sharpness...")
return ImageEnhance.Sharpness(image).enhance(enhance_factor)
# Filters
def __basic_filter(self, image, filter):
pass
def __blur(self, image, _args = []):
io_utils.sprint("Blurring...")
return image.filter(filter = ImageFilter.BLUR)
def __contour(self, image, _args = []):
io_utils.sprint("Contouring...")
return image.filter(filter = ImageFilter.CONTOUR)
def __detail(self, image, _args = []):
io_utils.sprint("Detailing...")
return image.filter(filter = ImageFilter.DETAIL)
def __enhance_edges(self, image, _args = []):
io_utils.sprint("Enhancing edges...")
return image.filter(filter = ImageFilter.EDGE_ENHANCE)
def __enhance_edges_more(self, image, _args = []):
io_utils.sprint("Enhancing edges...")
return image.filter(filter = ImageFilter.EDGE_ENHANCE_MORE)
def __find_edges(self, image, _args = []):
io_utils.sprint("Finding edges...")
return image.filter(filter = ImageFilter.FIND_EDGES)
def __emboss(self, image, _args = []):
io_utils.sprint("Embossing...")
return image.filter(filter = ImageFilter.EMBOSS)
def __sharpen(self, image, _args = []):
io_utils.sprint("Sharpening...")
return image.filter(filter = ImageFilter.SHARPEN)
def __smooth(self, image, _args = []):
io_utils.sprint("Smoothing...")
return image.filter(filter = ImageFilter.SMOOTH)
def __smooth_more(self, image, _args = []):
io_utils.sprint("Smoothing...")
return image.filter(filter = ImageFilter.SMOOTH_MORE)
def __grayscale(self, image, _args = []):
io_utils.sprint("Removing color...")
return ImageOps.grayscale(image)
def __invert(self, image, _args = []):
io_utils.sprint("Inverting...")
return ImageOps.invert(image)
def __posterize(self, image, num_bits = 4, _args = []):
io_utils.sprint("Posterizing...")
return ImageOps.posterize(image, num_bits)
def __solarize(self, image, greyscale_threshold = 128, _args = []):
io_utils.sprint("Solarizing...")
return ImageOps.solarize(image, greyscale_threshold)
# Masks
def __circle_mask(self, image, scale, _args = []):
large_dim = (image.size[0] * 3, image.size[1] * 3)
mask = Image.new('L', large_dim, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + large_dim, fill = 255)
mask = mask.resize(image.size, Image.ANTIALIAS)
image.putalpha(mask)
return image
def check_for_img_target(self, string):
return any_in_str([".png", ".jpg", ".jpeg", ".tiff", ".gif", ".raw", ".pdf"], string)
def get_query_type(self, query, get_tuple = False):
parts = query.split()
__query_type_map = {
# Scale
300: {
"conditions": [any_in_str(["scale", "enlargen", "embiggen", "larger"], query) or ("size" in query and "up" in query), any_in_str(["%", "percent", "perc"], query)],
"func": self.__scale,
"args": [1 + float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
301: {
"conditions": [any_in_str(["scale", "enlargen", "embiggen", "larger"], query) or ("size" in query and "up" in query), any_in_str(["factor", "times", "points"], query)],
"func": self.__scale,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
302: {
"conditions": [any_in_str(["scale", "shrink", "decrease", "smaller"], query) or ("size" in query and "down" in query), any_in_str(["%", "percent", "perc"], query)],
"func": self.__scale,
"args": [float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
303: {
"conditions": [any_in_str(["scale", "shrink", "decrease", "smaller"], query) or ("size" in query and "down" in query), any_in_str(["factor", "divided"], query)],
"func": self.__scale,
"args": [1/float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
304: {
"conditions": [any_in_str(["scale", "enlargen", "embiggen", "larger"], query) or ("size" in query and "up" in query)],
"func": self.__scale,
"args": [2],
},
305: {
"conditions": [any_in_str(["scale", "shrink", "decrease", "smaller"], query) or ("size" in query and "down" in query)],
"func": self.__scale,
"args": [1/2],
},
# Border
306: { # Border with color
"conditions": [any_in_str(["add", "give", "put", "attach", "affix", "surround", "bound", "enclose"], query), any_in_str(["border", "edge"], query) or ("spacing" in query and "around" in query), any_in_str(["of", "with", "px", "pixel", "spacing"], query), "color" in query],
"func": self.__add_border,
"args": re.compile(r'(?:color of |add a )([0-9]+|.*)').findall(query),
},
307: { # Border with width
"conditions": [any_in_str(["add", "give", "put", "attach", "affix", "surround", "bound", "enclose"], query), any_in_str(["border", "edge"], query) or ("spacing" in query and "around" in query), any_in_str(["of", "with", "px", "pixel", "spacing"], query)],
"func": self.__add_border,
"args": re.compile(r'([0-9]+)').findall(query),
},
308: { # Default border - 10 pixels
"conditions": [any_in_str(["add", "give", "put", "attach", "affix", "surround", "bound", "enclose"], query), any_in_str(["border", "edge"], query) or ("spacing" in query and "around" in query)],
"func": self.__add_border,
"args": [10],
},
# Enhancements
309: { # COLOR Enhance with factor
"conditions": [any_in_str(["enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "color" in query, any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_color,
"args": [1 + float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
310: {
"conditions": [any_in_str(["enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "color" in query, any_in_str(["factor", "times", "points"], query)],
"func": self.__enhance_color,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
311: {
"conditions": [any_in_str(["disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), "color" in query, any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_color,
"args": [float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
312: {
"conditions": [any_in_str(["disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), "color" in query, any_in_str(["factor", "divided"], query)],
"func": self.__enhance_color,
"args": [1/float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
313: { # Default increase color - 2x
"conditions": [any_in_str(["enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "color" in query],
"func": self.__enhance_color,
"args": [2],
},
314: { # Default decrease color - 1/2x
"conditions": [any_in_str(["disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), "color" in query],
"func": self.__enhance_color,
"args": [1/2],
},
315: { # CONTRAST enhance with factor
"conditions": [any_in_str(["enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "contrast" in query, any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_contrast,
"args": [1 + float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
316: {
"conditions": [any_in_str(["enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "contrast" in query, any_in_str(["factor", "times", "points"], query)],
"func": self.__enhance_contrast,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
317: {
"conditions": [any_in_str(["disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), "contrast" in query, any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_contrast,
"args": [float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
318: {
"conditions": [any_in_str(["disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), "contrast" in query, any_in_str(["factor", "divided"], query)],
"func": self.__enhance_contrast,
"args": [1/float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
319: { # Default increase contrast - 2x
"conditions": [any_in_str(["enchance", "improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "contrast" in query],
"func": self.__enhance_contrast,
"args": [2],
},
320: { # Default decrease contrast - 1/2x
"conditions": [any_in_str(["disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), "contrast" in query],
"func": self.__enhance_contrast,
"args": [1/2],
},
321: { # BRIGHTNESS enhance with factor
"conditions": [any_in_str(["brighten", "lighten", "enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), any_in_str(["dark", "light", "bright", "dim"], query), any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_brightness,
"args": [1 + float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
322: {
"conditions": [any_in_str(["brighten", "lighten", "enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), any_in_str(["dark", "light", "bright", "dim"], query), any_in_str(["factor", "times", "points"], query)],
"func": self.__enhance_brightness,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
323: {
"conditions": [any_in_str(["darken", "dim", "disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), any_in_str(["dark", "light", "bright", "dim"], query), any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_brightness,
"args": [float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
324: {
"conditions": [any_in_str(["darken", "dim", "disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), any_in_str(["dark", "light", "bright", "dim"], query), any_in_str(["factor", "divided"], query)],
"func": self.__enhance_brightness,
"args": [1/float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
325: { # Default increase brightness - 2x
"conditions": [any_in_str(["brighten", "lighten", "enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), any_in_str(["dark", "light", "bright", "dim"], query)],
"func": self.__enhance_brightness,
"args": [2],
},
326: { # Default decrease brightness - 1/2x
"conditions": [any_in_str(["darken", "dim", "disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), any_in_str(["dark", "light", "bright", "dim"], query)],
"func": self.__enhance_brightness,
"args": [1/2],
},
315: { # SHARPNESS enhance with factor
"conditions": [any_in_str(["sharpen", "enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), any_in_str(["smooth", "sharp"], query), any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_brightness,
"args": [1 + float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
327: {
"conditions": [any_in_str(["sharpen", "enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), any_in_str(["smooth", "sharp"], query), any_in_str(["factor", "times", "points"], query)],
"func": self.__enhance_sharpness,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
328: {
"conditions": [any_in_str(["smooth", "disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), any_in_str(["smooth", "sharp"], query), any_in_str(["%", "percent", "perc"], query)],
"func": self.__enhance_sharpness,
"args": [float(x)/100 for x in re.compile(r'([0-9]+)').findall(query)],
},
329: {
"conditions": [any_in_str(["smooth", "disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), any_in_str(["smooth", "sharp"], query), any_in_str(["factor", "divided"], query)],
"func": self.__enhance_sharpness,
"args": [1/float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
330: { # Default increase sharpness - 2x
"conditions": [any_in_str(["sharpen", "enchance","improve", "heighten", "increase", "increment", "upgrade", "raise", "lift", "elevate", "touch up", "turn up"], query), "sharp" in query],
"func": self.__enhance_sharpness,
"args": [2],
},
331: { # Default decrease sharpness - 1/2x
"conditions": [any_in_str(["smooth", "disenhance", "dehance", "lessen", "decrease", "decrement", "downgrade", "lower", "put down", "cutback", "drop", "turn down", "reduce", "shrink"], query), any_in_str(["smooth", "sharp"], query)],
"func": self.__enhance_sharpness,
"args": [1/2],
},
# Rotation
400: {
"conditions": ["rotate" in query or "turn" in query, "left" in query or "counter" in query, "degree" in query],
"func": self.__rotate_counterclockwise,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
401: {
"conditions": ["rotate" in query or "turn" in query, "left" in query or "counter" in query, "degree" not in query],
"func": self.__rotate_counterclockwise,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
500: {
"conditions": ["rotate" in query or "turn" in query, "right" in query or "clockwise" in query, "degree" in query],
"func": self.__rotate_clockwise,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
501: {
"conditions": ["rotate" in query or "turn" in query, "right" in query or "clockwise" in query, "degree" not in query],
"func": self.__rotate_clockwise,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
600: {
"conditions": ["rotate" in query or "turn" in query, "degree" in query],
"func": self.__rotate_clockwise,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
601: {
"conditions": ["rotate" in query or "turn" in query, "degree" not in query],
"func": self.__rotate_clockwise,
"args": [float(x) for x in re.compile(r'([0-9]+)').findall(query)],
},
# Filters
700: {
"conditions": ["blur" in query],
"func": self.__blur,
"args": [],
},
800: {
"conditions": ["sharpen" in query],
"func": self.__sharpen,
"args": [],
},
900: {
"conditions": ["smooth" in query],
"func": self.__smooth,
"args": [],
},
901: {
"conditions": ["contour" in query],
"func": self.__contour,
"args": [],
},
902: {
"conditions": ["detail" in query],
"func": self.__detail,
"args": [],
},
903: {
"conditions": ["emboss" in query],
"func": self.__emboss,
"args": [],
},
904: {
"conditions": ["enhance" in query, "edge" in query],
"func": self.__enhance_edges,
"args": [],
},
905: {
"conditions": ["find" in query, "edge" in query],
"func": self.__find_edges,
"args": [],
},
# Flip
906: {
"conditions": ["mirror" in query],
"func": self.__mirror,
"args": [],
},
1000: {
"conditions": [any_in_str(["horizon", "x", "left", "right"], query)],
"func": self.__flip_h,
"args": [],
},
1001: {
"conditions": [any_in_str(["vertical", "y", "top", "bottom", "up", "down"], query)],
"func": self.__flip_v,
"args": [],
},
# Mask
1002: {
"conditions": [any_in_str(["mask", "cover", "overlay", "fit", "cast", "cut"], query), any_in_str(["circle", "ellipse", "disk", "round"], query)],
"func": self.__circle_mask,
"args": [1],
},
}
for key, query_type in __query_type_map.items():
if all(query_type["conditions"]):
if ("these" in query or "this" in query) and "Finder" in context_utils.current_app:
key += 10000
elif "Finder" in context_utils.current_app and context_utils.get_selected_items() != []:
key += 5000
elif self.check_for_img_target(query) and not "Finder" in context_utils.current_app:
key += 1000
elif "Finder" in context_utils.current_app and self.check_for_img_target(query):
pass
else:
# Finder isn't open, no file ref provided --> give this to another command to handle
return 0
if get_tuple:
return (key, query_type)
return key
return 0
def get_template(self, new_cmd_name):
print("Enter base command and args: ")
cmd_new = input()
query_length = len(new_cmd_name)+1
template = {
'command': str(cmd_new.split(" ")),
}
return template
command = ImgCmd()