Hello, do you know any way so that instead of giving me the length it gives me the date, day and time of the photo?
Bit obscure but you can get the info with a python node like this
Code
from System.Drawing import Image
img = Image.FromFile(IN[0])
OUT = ''.join(map(chr, img.GetPropertyItem(0x0132).Value))
See here for other properties PropertyItem.Id Property
Cool!!
This is great. Thanks
Thanks
@Mike.Buttery,I think the question is a bit simple, this works very well when it is a single image, could you help me modify it so that it works just as well on a photo file?
Here’s some python (python 3) that can read a file path or a folder path and return (filename, date_time)
pairs
Place this in a python node rather than Python Script From String
# Python 3
from pathlib import Path
from System.Drawing import Image
def image_datetime(imgfile):
img = Image.FromFile(str(imgfile))
return ''.join(map(chr, img.GetPropertyItem(0x0132).Value))
path = Path(IN[0])
if Path(path).is_file():
OUT = path.name, image_datetime(path)
elif Path(path).is_dir():
image_ext = ['bmp', 'tif*', 'png', 'jp*g']
img_paths = [p for imgext in image_ext for p in path.glob(f'**/*.{imgext}')]
OUT = [(img_path.name, image_datetime(img_path)) for img_path in img_paths]
else:
OUT = None
Change the input to ‘paths’ instead of path.
Indent everything else out by one level, and prepend ‘for path in paths’ before it.
If you want to see all the data you will need to add a men’s of appending he data into a list as well.
thanks
The code is only expecting one path to either a file or a directory - it will find the images if required