Skip to content

Commit a3c7699

Browse files
committed
updated readme and few details
1 parent 9e05bb0 commit a3c7699

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,38 @@
33
A collection of small scripts written in Python and implemented as command line utility programs.
44

55
#### [Batch Resizer](https://github.com/herokunt/python-scripts/blob/main/batch-resizer.py)
6-
Batch resizer is a small utility script that looks at a directory and processes all images in it in some way. You can resize them, convert them into other formats or bundle them together in a nice compressed archive, ready to be uploaded. Some examples:
6+
Process images by converting them to different formats, resizing them and store them as compressed archives for easy upload to your cloud. You may provide one or more images and they'll be processed in parallel for extra speed. File metadata like GPS location, camera model, etc., is completely removed.
7+
8+
- TODO: add support to embed watermark image
9+
- TODO: add support to resize to multiple sizes at once
10+
- TODO: create output directory if does not exist
711

812
```
9-
# Resize all images to a specified width and height (aspect ratio preserved)
10-
$ resizer.py ~/Pictures --resize 1200 1200
13+
# Resize images to a specified width and height (aspect ratio preserved)
14+
$ resizer.py ~/Pictures/* --resize 600 600
15+
16+
# Convert images to the specified format or formats (JPEG, PNG or WEBP)
17+
$ resizer.py ~/Pictures/* --format jpeg webp
1118
12-
# Convert all images to the specified format (jpg, png or webp)
13-
$ resizer.py ~/Pictures --format webp
19+
# Provide target directory for output images
20+
$ resizer.py ~/Pictures/* --output ~/Desktop
21+
22+
# Create an archive for the output processed images with a custom name
23+
$ resizer.py ~/Pictures/* -o ~/Desktop -t backup
24+
```
1425

15-
# Add a watermark to all images:
16-
$ resizer.py ~/Pictures --watermark ~/logo.png
26+
---
27+
#### [Password Checker](https://github.com/herokunt/python-scripts/blob/main/password_checker.py)
28+
Check your passwords against the popular "Have I Been Pwned?" website and find out if they've been leaked in any of the increasingly common data breaches. Your passwords provided to the script will remain secured as only a hash is used, as per the Have I Been Pwned API requires.
1729

18-
# Resize images to 1200x1200 pixels, convert them to webp format,
19-
# store them in the desktop, compressed as a .tar.gz archive and delete all of the
20-
# original images afterwards
21-
$ resizer.py ~/Pictures -o ~/Desktop -r 1200 1200 -f webp -t -d
30+
You can provide passwords inline or through a CSV file, ideal if your password manager (such as KeePassXC) supports exporting data in CSV format. For security you can instruct the script to securely delete that file from your hard drive by overwriting the original contents with random bytes before deleting it.
31+
32+
```
33+
$ ./password_checker.py password1 123456 -f ~/Desktop/path_to_file.csv --delete --verbose
34+
Found match for "Gmail" 1444 times!
35+
Found match for "pas..." 2427158 times!
36+
Found match for "123..." 24230577 times!
37+
DEBUG:root:Securely deleting file (3 rounds...)
2238
```
2339

2440
---
@@ -45,20 +61,6 @@ Total size.................................657.9MB
4561
Total lines of code.......................14504117
4662
```
4763

48-
---
49-
#### [Password Checker](https://github.com/herokunt/python-scripts/blob/main/password_checker.py)
50-
Check your passwords against the popular "Have I Been Pwned?" website and find out if they've been leaked in any of the increasingly common data breaches. Your passwords provided to the script will remain secured as only a hash is used, as per the Have I Been Pwned API requires.
51-
52-
You can provide passwords inline or through a CSV file, ideal if your password manager (such as KeePassXC) supports exporting data in CSV format. For security you can instruct the script to securely delete that file from your hard drive by overwriting the original contents with random bytes before deleting it.
53-
54-
```
55-
$ ./password_checker.py password1 123456 -f ~/Desktop/path_to_file.csv --delete --verbose
56-
Found match for "Gmail" 1444 times!
57-
Found match for "pas..." 2427158 times!
58-
Found match for "123..." 24230577 times!
59-
DEBUG:root:Securely deleting file (3 rounds...)
60-
```
61-
6264
---
6365
#### [Nama Nama](https://github.com/herokunt/python-scripts/blob/main/nama_nama.py)
6466
"Nama" means name in some languages such as Malay or Indonesian. This small utility script will help organize any collection of files by renaming them uniformly, adding prefixes and sufixes, custom separators, etc. Ideal for music, images, books and other types of documents that have uneven format (mixed of uppercase and lowercase, underscores with spaces, etc). Before, and after:

batch-resizer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
"""
44
Process images by converting them to different formats, resizing them and store
5-
them as compressed archives for easy uplaod to your cloud. You may provide one
5+
them as compressed archives for easy upload to your cloud. You may provide one
66
or more images and they'll be processed in parallel for extra speed.
77
8-
usage: imgtest.py [-h] [-v] [-o [OUTPUT]] [-r WIDTH HEIGHT]
8+
usage: batch-resizer.py [-h] [-v] [-o [OUTPUT]] [-r WIDTH HEIGHT]
99
[-f {webp,jpeg,jpg,png} [{webp,jpeg,jpg,png} ...]]
1010
[-z | -t [ARCHIVE]]
1111
input [input ...]
@@ -48,9 +48,6 @@ def main():
4848

4949
if args.verbose:
5050
logging.basicConfig(level=logging.DEBUG)
51-
print('Dimensions:', args.dimensions)
52-
print('Output:', args.output)
53-
print('Convert to:', args.format)
5451
print(f'Found {len(images)} images:')
5552

5653
# Process each file using multi-processing, returns extensions used
@@ -81,6 +78,9 @@ def make_archive(args, input, formats):
8178
file_to_add = f'{args.output}{os.path.sep}resized-{img}.{ext}'
8279
tar.add(file_to_add, arcname=f'resized-{img}.{ext}')
8380

81+
# Delete the file once is moved into the archive
82+
os.remove(file_to_add)
83+
8484

8585
def process_image(image, args):
8686
'''Takes an image file path and process it according to provided arguments'''

0 commit comments

Comments
 (0)