mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Image import: Make Exif handling more tolerant, better info,...
Changes to the "Add pictures to dive" function: - Make Exif handling more tolerant by removing the JPG sanity check for EOI - Give info to user if exif.cpp can't identify a Exif date/time - Restrict file dialog filter for correct picture time by DC photo to JPG because Exif is only available from JPG Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
		
							parent
							
								
									0617308b39
								
							
						
					
					
						commit
						59bbaa7820
					
				
					 2 changed files with 5 additions and 19 deletions
				
			
		|  | @ -420,23 +420,6 @@ int easyexif::EXIFInfo::parseFrom(const unsigned char *buf, unsigned len) { | |||
|   if (!buf || len < 4) return PARSE_EXIF_ERROR_NO_JPEG; | ||||
|   if (buf[0] != 0xFF || buf[1] != 0xD8) return PARSE_EXIF_ERROR_NO_JPEG; | ||||
| 
 | ||||
|   // Sanity check: some cameras pad the JPEG image with null bytes at the end.
 | ||||
|   // Normally, we should able to find the JPEG end marker 0xFFD9 at the end
 | ||||
|   // of the image, but not always. As long as there are null/0xFF bytes at the
 | ||||
|   // end of the image buffer, keep decrementing len until an 0xFFD9 is found,
 | ||||
|   // or some other bytes are. If the first non-zero/0xFF bytes from the end are
 | ||||
|   // not 0xFFD9, then we can be reasonably sure that the buffer is not a JPEG.
 | ||||
|   while (len > 2) { | ||||
|     if (buf[len - 1] == 0 || buf[len - 1] == 0xFF) { | ||||
|       len--; | ||||
|     } else { | ||||
|       if (buf[len - 1] != 0xD9 || buf[len - 2] != 0xFF) { | ||||
|         return PARSE_EXIF_ERROR_NO_JPEG; | ||||
|       } else { | ||||
|         break; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   clear(); | ||||
| 
 | ||||
|   // Scan for EXIF header (bytes 0xFF 0xE1) and do a sanity check by
 | ||||
|  |  | |||
|  | @ -309,7 +309,7 @@ void ShiftImageTimesDialog::syncCameraClicked() | |||
| 	QStringList fileNames = QFileDialog::getOpenFileNames(this, | ||||
| 							      tr("Open image file"), | ||||
| 							      DiveListView::lastUsedImageDir(), | ||||
| 							      tr("Image files (*.jpg *.jpeg *.pnm *.tif *.tiff)")); | ||||
| 							      tr("Image files (*.jpg *.jpeg)")); | ||||
| 	if (fileNames.isEmpty()) | ||||
| 		return; | ||||
| 
 | ||||
|  | @ -401,7 +401,10 @@ void ShiftImageTimesDialog::updateInvalid() | |||
| 		// We've found invalid image
 | ||||
| 		timestamp = picture_get_timestamp(fileName.toUtf8().data()); | ||||
| 		time_first.setTime_t(timestamp + m_amount); | ||||
| 		ui.invalidFilesText->append(fileName + " " + time_first.toString()); | ||||
| 		if (timestamp == 0) | ||||
| 			ui.invalidFilesText->append(fileName + " - " + tr("No Exif date/time found")); | ||||
| 		else | ||||
| 			ui.invalidFilesText->append(fileName + " - " + time_first.toString()); | ||||
| 		allValid = false; | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue