[LABI] tema07 parts 1 and 2 done

This commit is contained in:
Tiago Garcia 2023-06-19 12:38:02 +01:00
parent c1eaea544c
commit d8fe986dcd
No known key found for this signature in database
GPG Key ID: F423E37A2415E160
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])