mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-28 07:39:49 +08:00
This commit is contained in:
parent
42ebc42c98
commit
38e03e6bb0
@ -123,6 +123,9 @@
|
||||
<Content Include="Test.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="TestMetadataIssue2447.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="TestPortrait.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -30,6 +30,18 @@ namespace ImageResizer.Models
|
||||
image => Assert.Equal("Test", ((BitmapMetadata)image.Frames[0].Metadata).Comment));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExecuteCopiesFrameMetadataExceptWhenMetadataCannotBeCloned()
|
||||
{
|
||||
var operation = new ResizeOperation("TestMetadataIssue2447.jpg", _directory, Settings());
|
||||
|
||||
operation.Execute();
|
||||
|
||||
AssertEx.Image(
|
||||
_directory.File(),
|
||||
image => Assert.Null(((BitmapMetadata)image.Frames[0].Metadata).CameraModel));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExecuteKeepsDateModified()
|
||||
{
|
||||
|
BIN
src/modules/imageresizer/tests/TestMetadataIssue2447.jpg
Normal file
BIN
src/modules/imageresizer/tests/TestMetadataIssue2447.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 MiB |
@ -64,11 +64,25 @@ namespace ImageResizer.Models
|
||||
|
||||
foreach (var originalFrame in decoder.Frames)
|
||||
{
|
||||
BitmapMetadata metadata = (BitmapMetadata)originalFrame.Metadata;
|
||||
if (metadata != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Detect whether metadata can copied successfully
|
||||
_ = metadata.Clone();
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
metadata = null;
|
||||
}
|
||||
}
|
||||
|
||||
encoder.Frames.Add(
|
||||
BitmapFrame.Create(
|
||||
Transform(originalFrame),
|
||||
thumbnail: null,
|
||||
(BitmapMetadata)originalFrame.Metadata, // TODO: Add an option to strip any metadata that doesn't affect rendering (issue #3)
|
||||
metadata, // TODO: Add an option to strip any metadata that doesn't affect rendering (issue #3)
|
||||
colorContexts: null));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user