[Image Resizer]Try to recover metadata even when the metadata data structure is invalid (#14914)

* metadata.Clone() fails also for situations where we still can recover metadata

metadata.Clone() is also an expensive operation (deep copy) and it is not necessary anymore as we build up the metadata object from scratch anyway

* If an exception is throw here something is seriously wrong with the metadata structure

We take all metadata we have read so far an write it to the resized image

* add log statement

* Adjust test written for #2447 as we are able to copy the metadata now

* Improve documentation
This commit is contained in:
CleanCodeDeveloper
2021-12-10 14:54:05 +01:00
committed by GitHub
parent 1e0033166f
commit 9152ea8f1c
3 changed files with 35 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ namespace ImageResizer.Models
}
[TestMethod]
public void ExecuteCopiesFrameMetadataExceptWhenMetadataCannotBeCloned()
public void ExecuteCopiesFrameMetadataEvenWhenMetadataCannotBeCloned()
{
var operation = new ResizeOperation("TestMetadataIssue2447.jpg", _directory, Settings());
@@ -41,7 +41,7 @@ namespace ImageResizer.Models
AssertEx.Image(
_directory.File(),
image => Assert.IsNull(((BitmapMetadata)image.Frames[0].Metadata).CameraModel));
image => Assert.IsNotNull(((BitmapMetadata)image.Frames[0].Metadata).CameraModel));
}
[TestMethod]