Exif je zběsilej standard
This commit is contained in:
		
							parent
							
								
									2cbaee10aa
								
							
						
					
					
						commit
						a44fcce1c8
					
				
					 1 changed files with 10 additions and 1 deletions
				
			
		|  | @ -123,7 +123,16 @@ class Galerie(models.Model): | ||||||
| 				raise ValueError from e | 				raise ValueError from e | ||||||
| 
 | 
 | ||||||
| 			exif = obr.getexif() # Pokud tam není, tak si Pillow podle zdrojáků vyhaluzí prázdný. | 			exif = obr.getexif() # Pokud tam není, tak si Pillow podle zdrojáků vyhaluzí prázdný. | ||||||
| 			date_str = exif.get(ExifTags.Base.DateTime, None) or exif.get(ExifTags.Base.DateTimeOriginal, None) or exif.get(ExifTags.Base.DateTimeDigitized, None) | 			ifd_exif = {} | ||||||
|  | 			if ExifTags.IFD.Exif in exif: ifd_exif = exif.get_ifd(ExifTags.IFD.Exif) | ||||||
|  | 			date_str = (False # zarovnání | ||||||
|  | 				or exif.get(ExifTags.Base.DateTimeOriginal, None) | ||||||
|  | 				or ifd_exif.get(ExifTags.Base.DateTimeOriginal, None) | ||||||
|  | 				or exif.get(ExifTags.Base.DateTime, None) | ||||||
|  | 				or ifd_exif.get(ExifTags.Base.DateTime, None) | ||||||
|  | 				or exif.get(ExifTags.Base.DateTimeDigitized, None) | ||||||
|  | 				or ifd_exif.get(ExifTags.Base.DateTimeDigitized, None) | ||||||
|  | 				) | ||||||
| 			if date_str is None: continue | 			if date_str is None: continue | ||||||
| 			dt = datetime.strptime(date_str, EXIF_DATETIME_FMT) | 			dt = datetime.strptime(date_str, EXIF_DATETIME_FMT) | ||||||
| 			poradi = int(dt.strftime("1%d%H%M%S")) | 			poradi = int(dt.strftime("1%d%H%M%S")) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 LEdoian
						LEdoian