File tree 1 file changed +10
-6
lines changed
IMAGES & PHOTO SCRIPTS/Image-Inverter 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 5
5
import sys , os
6
6
7
7
def main ():
8
+ # if the script is called with no input
8
9
if len (sys .argv ) == 1 :
9
10
print ("Please provide files to operate on!" )
10
11
sys .exit (1 )
11
12
12
- for file in sys .argv : # TODO: remove the sys.argv[0] from the loop! use index i and start from 1
13
- # TODO: add a check that the files are jpg
13
+ i = 0
14
+ for file in sys .argv :
15
+ # ignore the first parameter -> the script call
16
+ if i == 0 :
17
+ i = i + 1
18
+ continue
19
+
14
20
file_name = os .path .splitext (file )
15
21
with Image .open (file ) as image :
16
- inverted_image = ImageOps .invert (image )
17
- inverted_image .save (filename + "_inverted" , "JPEG" )
18
-
19
- sys .exit (0 )
22
+ ImageOps .invert (image ).save (filename + "_inverted" , "JPEG" )
23
+ i = i + 1
20
24
21
25
if __name__ == '__main__' :
22
26
main ()
You can’t perform that action at this time.
0 commit comments