WIP: use code from labthings-picamera2 for EXIF writing
I've now switched to using piexif to write the EXIF tag, which is slower - but still does not seem to work in openflexure- stitching.
This commit is contained in:
parent
bc8db396bf
commit
a61ffbf75a
1 changed files with 6 additions and 8 deletions
|
|
@ -582,19 +582,17 @@ class SmartScanThing(Thing):
|
||||||
processed = rggb2rgb(raw2rggb(raw_image)) / white_norm
|
processed = rggb2rgb(raw2rggb(raw_image)) / white_norm
|
||||||
processed[processed > 255] = 255
|
processed[processed > 255] = 255
|
||||||
processed[processed < 0] = 0
|
processed[processed < 0] = 0
|
||||||
img = Image.fromarray(processed, mode="RGB")
|
img = Image.fromarray(processed.astype(np.uint8), mode="RGB")
|
||||||
img.save(
|
img.save(
|
||||||
os.path.join(images_folder, name),
|
os.path.join(images_folder, name),
|
||||||
exif=json.dumps(
|
|
||||||
{
|
|
||||||
"Exif": {
|
|
||||||
piexif.ExifIFD.UserComment: metadata_getter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).encode("utf-8"),
|
|
||||||
quality=95,
|
quality=95,
|
||||||
subsampling=0
|
subsampling=0
|
||||||
)
|
)
|
||||||
|
exif_dict = piexif.load(os.path.join(images_folder, name))
|
||||||
|
exif_dict["Exif"][piexif.ExifIFD.UserComment] = json.dumps(
|
||||||
|
metadata_getter()
|
||||||
|
).encode("utf-8")
|
||||||
|
piexif.insert(piexif.dump(exif_dict), os.path.join(images_folder, name))
|
||||||
save_time = time.time()
|
save_time = time.time()
|
||||||
logger.info(f"Acquired {name} in {acquisition_time-capture_start:.1f}s then {save_time-acquisition_time:.1f}s saving to disk")
|
logger.info(f"Acquired {name} in {acquisition_time-capture_start:.1f}s then {save_time-acquisition_time:.1f}s saving to disk")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue