28 lines
660 B
Python
28 lines
660 B
Python
import os
|
|
import cv2
|
|
from exif import Image
|
|
|
|
file_name = "adam.jpg"
|
|
|
|
if not os.path.exists(file_name):
|
|
print(f"Brak pliku: {file_name}")
|
|
# kod błedu na podstawie https://questdb.com/docs/troubleshooting/os-error-codes/
|
|
exit(5)
|
|
|
|
with open(file_name, 'rb') as image_file:
|
|
image = Image(image_file)
|
|
|
|
print(image.list_all())
|
|
|
|
# czytamy plik
|
|
flags = cv2.IMREAD_COLOR
|
|
img = cv2.imread(file_name, flags)
|
|
print(f"Rozmiary obrazka to: {img.shape=}")
|
|
rozmiary_exif = f"""
|
|
Wymiary to {image.x_resolution} x {image.y_resolution}
|
|
Unit {image.resolution_unit=}
|
|
"""
|
|
print(rozmiary_exif)
|
|
cv2.imshow("nazwa okienka", img)
|
|
cv2.waitKey(0)
|
|
cv2.destroyAllWindows() |