Skip to content

Commit cd10b83

Browse files
committed
Added heic security defines that were added to ImageMagick.
1 parent ae17720 commit cd10b83

9 files changed

+240
-0
lines changed

src/Magick.NET/Formats/Heic/HeicReadDefines.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,41 @@ public sealed class HeicReadDefines : IReadDefines
2727
public MagickFormat Format
2828
=> MagickFormat.Heic;
2929

30+
/// <summary>
31+
/// Gets or sets the maximum bayer pattern size (heic:max-bayer-pattern-pixels).
32+
/// </summary>
33+
public uint? MaxBayerPatternPixels { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the maximum number of children per box (heic:max-children-per-box).
37+
/// </summary>
38+
public uint? MaxChildrenPerBox { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the maximum number of components (heic:max-components).
42+
/// </summary>
43+
public uint? MaxComponents { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets themaximum number of extents in iloc box (heic:max-iloc-extents-per-item).
47+
/// </summary>
48+
public uint? MaxIlocExtentsPerItem { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets the maximum number of items in a box (heic:max-items).
52+
/// </summary>
53+
public uint? MaxItems { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the maximum number of tiles (heic:max-number-of-tiles).
57+
/// </summary>
58+
public ulong? MaxNumberOfTiles { get; set; }
59+
60+
/// <summary>
61+
/// Gets or sets the maximum size of an entity group (heic:max-size-entity-group).
62+
/// </summary>
63+
public uint? MaxSizeEntityGroup { get; set; }
64+
3065
/// <summary>
3166
/// Gets or sets a value indicating whether the orientation should be preserved (heic:preserve-orientation).
3267
/// </summary>
@@ -46,6 +81,27 @@ public IEnumerable<IDefine> Defines
4681
if (DepthImage == true)
4782
yield return new MagickDefine(Format, "depth-image", DepthImage.Value);
4883

84+
if (MaxBayerPatternPixels is not null)
85+
yield return new MagickDefine(Format, "max-bayer-pattern-pixels", MaxBayerPatternPixels.Value);
86+
87+
if (MaxChildrenPerBox is not null)
88+
yield return new MagickDefine(Format, "max-children-per-box", MaxChildrenPerBox.Value);
89+
90+
if (MaxComponents is not null)
91+
yield return new MagickDefine(Format, "max-components", MaxComponents.Value);
92+
93+
if (MaxIlocExtentsPerItem is not null)
94+
yield return new MagickDefine(Format, "max-iloc-extents-per-item", MaxIlocExtentsPerItem.Value);
95+
96+
if (MaxItems is not null)
97+
yield return new MagickDefine(Format, "max-items", MaxItems.Value);
98+
99+
if (MaxNumberOfTiles is not null)
100+
yield return new MagickDefine(Format, "max-number-of-tiles", MaxNumberOfTiles.Value);
101+
102+
if (MaxSizeEntityGroup is not null)
103+
yield return new MagickDefine(Format, "max-size-entity-group", MaxSizeEntityGroup.Value);
104+
49105
if (PreserveOrientation == true)
50106
yield return new MagickDefine(Format, "preserve-orientation", PreserveOrientation.Value);
51107
}

tests/Magick.NET.Tests/Formats/Heic/HeicReadDefinesTests/TheConstructor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ public void ShouldNotSetAnyDefines()
2020
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "chroma-upsampling"));
2121
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "depth-image"));
2222
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "preserve-orientation"));
23+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-bayer-pattern-pixels"));
24+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-children-per-box"));
25+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-components"));
26+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-iloc-extents-per-item"));
27+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-items"));
28+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-number-of-tiles"));
29+
Assert.Null(image.Settings.GetDefine(MagickFormat.Heic, "max-size-entity-group"));
2330
}
2431
}
2532
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxBayerPatternPixelsProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxBayerPatternPixels = 42,
21+
});
22+
23+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-bayer-pattern-pixels"));
24+
}
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxChildrenPerBoxProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxChildrenPerBox = 42,
21+
});
22+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-children-per-box"));
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxComponentsProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxComponents = 42,
21+
});
22+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-components"));
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxIlocExtentsPerItemProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxIlocExtentsPerItem = 42,
21+
});
22+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-iloc-extents-per-item"));
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxItemsProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxItems = 42,
21+
});
22+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-items"));
23+
}
24+
}
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxNumberOfTilesProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxNumberOfTiles = 42,
21+
});
22+
23+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-number-of-tiles"));
24+
}
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using ImageMagick.Formats;
6+
using Xunit;
7+
8+
namespace Magick.NET.Tests;
9+
10+
public partial class HeicReadDefinesTests
11+
{
12+
public class TheMaxSizeEntityGroupProperty
13+
{
14+
[Fact]
15+
public void ShouldSetTheDefine()
16+
{
17+
using var image = new MagickImage();
18+
image.Settings.SetDefines(new HeicReadDefines
19+
{
20+
MaxSizeEntityGroup = 42,
21+
});
22+
Assert.Equal("42", image.Settings.GetDefine(MagickFormat.Heic, "max-size-entity-group"));
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)