Update xmp only if needed.
Should fix crash on certain images (sequence jgmvtIOe08rSpzHqNyR2hQ)
This commit is contained in:
parent
c7a2f714bd
commit
d3c69c2027
|
@ -26,7 +26,7 @@ def parse_args(argv =None):
|
||||||
parser.add_argument('--destination', type=str, default='data', help='Path destination for the images')
|
parser.add_argument('--destination', type=str, default='data', help='Path destination for the images')
|
||||||
parser.add_argument('--image_limit', type=int, default=None, help='How many images you want to download')
|
parser.add_argument('--image_limit', type=int, default=None, help='How many images you want to download')
|
||||||
parser.add_argument('--overwrite', default=False, action='store_true', help='overwrite existing images')
|
parser.add_argument('--overwrite', default=False, action='store_true', help='overwrite existing images')
|
||||||
parser.add_argument("-v", "--version", action="version", version="release 1.5")
|
parser.add_argument("-v", "--version", action="version", version="release 1.6")
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
if args.sequence_ids is None and args.image_ids is None:
|
if args.sequence_ids is None and args.image_ids is None:
|
||||||
parser.error("Please enter at least one sequence id or image id")
|
parser.error("Please enter at least one sequence id or image id")
|
||||||
|
@ -163,6 +163,8 @@ if __name__ == '__main__':
|
||||||
direction = image_data['compass_angle'],
|
direction = image_data['compass_angle'],
|
||||||
altitude = image_data['altitude'],
|
altitude = image_data['altitude'],
|
||||||
)
|
)
|
||||||
|
#print("metadata: ", img_metadata)
|
||||||
|
#print("path: ", image_data)
|
||||||
image_exists = os.path.exists(path)
|
image_exists = os.path.exists(path)
|
||||||
if not args.overwrite and image_exists:
|
if not args.overwrite and image_exists:
|
||||||
print("{} already exists. Skipping ".format(path))
|
print("{} already exists. Skipping ".format(path))
|
||||||
|
|
|
@ -47,8 +47,13 @@ class Writer():
|
||||||
self.image.close()
|
self.image.close()
|
||||||
|
|
||||||
def apply(self) -> None:
|
def apply(self) -> None:
|
||||||
|
try:
|
||||||
|
if self.updated_exif:
|
||||||
self.image.modify_exif(self.updated_exif)
|
self.image.modify_exif(self.updated_exif)
|
||||||
|
if self.updated_xmp:
|
||||||
self.image.modify_xmp(self.updated_xmp)
|
self.image.modify_xmp(self.updated_xmp)
|
||||||
|
except Exception as e:
|
||||||
|
print("exception \nexif: {}\nxmp: {}".format(self.updated_exif, self.updated_xmp))
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
self.image.close()
|
self.image.close()
|
||||||
|
|
Loading…
Reference in New Issue