Skip to content

Commit cd69a67

Browse files
committed
Delete Image Metadata Script Added
1 parent 5e2d501 commit cd69a67

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

Delete Image Metadata/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Delete Image Metadata
2+
[![forthebadge](https://forthebadge.com/images/badges/built-with-grammas-recipe.svg)](https://forthebadge.com)
3+
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
4+
[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)
5+
[![forthebadge](https://forthebadge.com/images/badges/powered-by-water.svg)](https://forthebadge.com)
6+
7+
The python script deletes all the metadata from the image
8+
9+
What the program does?
10+
- Takes image file(s) as input at the same time
11+
- Deletes all the metadata from the image
12+
13+
### Requirements
14+
>Python3.6+
15+
>
16+
> pip install -r requirements.txt
17+
18+
19+
### Usage
20+
```
21+
delImg_meta.py [-h] -f FILES [FILES ...]
22+
23+
DELETE METADATA IN IMAGES
24+
25+
optional arguments:
26+
-h, --help show this help message and exit
27+
-f FILES [FILES ...] Image File(s)
28+
```
29+
30+
### Contribution
31+
Any kind of contributions are welcome
32+
1. Fork the project
33+
2. Commit your changes
34+
3. Open a pull request
35+
36+

Delete Image Metadata/delImg_meta.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import argparse
2+
import PIL
3+
from PIL import Image
4+
5+
6+
def img_data_delete(files):
7+
for file in files:
8+
9+
# try, except block
10+
try:
11+
12+
# Open image file
13+
image = Image.open(file)
14+
15+
# Getting the original image mode and size
16+
stripped = Image.new(image.mode, image.size)
17+
18+
# Cleaning and saving the file
19+
stripped.putdata(list(image.getdata()))
20+
stripped.save(f"clean_{file}")
21+
22+
print(f"Clean Image File: clean_{file}")
23+
24+
except PIL.UnidentifiedImageError:
25+
print(f"Cannot Identify Image: {file}")
26+
27+
except IOError:
28+
print(f'Problem Reading Image: {file}')
29+
30+
31+
def main():
32+
parser = argparse.ArgumentParser(description='DELETE METADATA IN IMAGES')
33+
34+
# Argument is for images files
35+
parser.add_argument('-f', dest='files', nargs='+', type=str, help='Image File(s)', required=True)
36+
37+
args = parser.parse_args()
38+
39+
# Get the files
40+
files = args.files
41+
42+
if files:
43+
img_data_delete(files)
44+
45+
46+
if __name__ == '__main__':
47+
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pillow==8.1.0

0 commit comments

Comments
 (0)