mirror of
				https://forge.chapril.org/tykayn/mapillary_download
				synced 2025-10-09 17:02:46 +02:00 
			
		
		
		
	Update xmp only if needed.
Should fix crash on certain images (sequence jgmvtIOe08rSpzHqNyR2hQ)
This commit is contained in:
		
							parent
							
								
									c7a2f714bd
								
							
						
					
					
						commit
						d3c69c2027
					
				
					 2 changed files with 10 additions and 3 deletions
				
			
		|  | @ -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: | ||||||
|         self.image.modify_exif(self.updated_exif) |         try: | ||||||
|         self.image.modify_xmp(self.updated_xmp) |             if self.updated_exif: | ||||||
|  |                 self.image.modify_exif(self.updated_exif) | ||||||
|  |             if 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…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Stefal
						Stefal