[LABI] tema07 parts 1 and 2 done

This commit is contained in:
Tiago Garcia 2023-06-19 12:38:02 +01:00
parent 826bec9e90
commit 301b849d45
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
6 changed files with 40 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

View File

@ -0,0 +1,22 @@
from PIL import Image, ExifTags
import sys
def main(fname):
img = Image.open(fname)
width, height = img.size
print("Width: %dpx" % width)
print("Height: %dpx" % height)
print("Format: %s" % img.format)
tags = img._getexif()
for tag, value in tags.items():
decoded = ExifTags.TAGS.get(tag, tag)
print("%s: %s" % (decoded, value))
if __name__ == '__main__':
main(sys.argv[1])

View File

@ -0,0 +1,18 @@
from PIL import Image, ExifTags
import sys
def main(file):
img = Image.open(file)
fname = '.'.join(file.split(".")[:-1]), file.split(".")[-1]
width, height = img.size
for s in [0.2, 8]:
dimension = (int(width * s), int(height * s))
new_img = img.resize(dimension, Image.NEAREST)
new_img.save(fname[0]+"-%.2f.%s" % (s, fname[1]))
if __name__ == '__main__':
main(sys.argv[1])