mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
This commit is contained in:
@@ -123,6 +123,9 @@
|
|||||||
<Content Include="Test.png">
|
<Content Include="Test.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="TestMetadataIssue2447.jpg">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="TestPortrait.png">
|
<Content Include="TestPortrait.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ namespace ImageResizer.Models
|
|||||||
image => Assert.Equal("Test", ((BitmapMetadata)image.Frames[0].Metadata).Comment));
|
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]
|
[Fact]
|
||||||
public void ExecuteKeepsDateModified()
|
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)
|
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(
|
encoder.Frames.Add(
|
||||||
BitmapFrame.Create(
|
BitmapFrame.Create(
|
||||||
Transform(originalFrame),
|
Transform(originalFrame),
|
||||||
thumbnail: null,
|
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));
|
colorContexts: null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user