From 4645e407259f5296c057d1bfe98821778040f8e6 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Fri, 29 Dec 2023 14:10:25 +0100 Subject: [PATCH] Rename namespace and classes to Heif --- .gitattributes | 4 - src/ImageSharp/Configuration.cs | 6 +- .../Formats/Heic/HeicConfigurationModule.cs | 18 -- .../Heif4CharCode.cs} | 6 +- .../Heif4CharCode.tt} | 6 +- .../HeifCompressionMethod.cs} | 4 +- .../Formats/Heif/HeifConfigurationModule.cs | 18 ++ .../HeifConstants.cs} | 8 +- .../HeicDecoder.cs => Heif/HeifDecoder.cs} | 14 +- .../HeifDecoderCore.cs} | 201 +++++++++--------- .../HeicEncoder.cs => Heif/HeifEncoder.cs} | 10 +- .../HeifEncoderCore.cs} | 92 ++++---- .../HeicFormat.cs => Heif/HeifFormat.cs} | 14 +- .../HeifImageFormatDetector.cs} | 12 +- .../{Heic/HeicItem.cs => Heif/HeifItem.cs} | 10 +- .../HeicItemLink.cs => Heif/HeifItemLink.cs} | 8 +- .../HeicLocation.cs => Heif/HeifLocation.cs} | 6 +- .../HeicMetadata.cs => Heif/HeifMetadata.cs} | 18 +- .../{Heic => Heif}/IHeicEncoderOptions.cs | 4 +- .../{Heic => Heif}/MetadataExtensions.cs | 8 +- .../Formats/{Heic => Heif}/Readme.md | 0 src/ImageSharp/ImageSharp.csproj | 8 +- .../HeifDecoderTests.cs} | 28 +-- .../HeifEncoderTests.cs} | 18 +- .../Formats/ImageFormatManagerTests.cs | 6 +- tests/ImageSharp.Tests/TestImages.cs | 16 +- .../TestUtilities/TestEnvironment.Formats.cs | 4 +- .../Decode_Rgba32_IMG-20230508-0053.png | 0 28 files changed, 274 insertions(+), 273 deletions(-) delete mode 100644 src/ImageSharp/Formats/Heic/HeicConfigurationModule.cs rename src/ImageSharp/Formats/{Heic/Heic4CharCode.cs => Heif/Heif4CharCode.cs} (96%) rename src/ImageSharp/Formats/{Heic/Heic4CharCode.tt => Heif/Heif4CharCode.tt} (94%) rename src/ImageSharp/Formats/{Heic/HeicCompressionMethod.cs => Heif/HeifCompressionMethod.cs} (90%) create mode 100644 src/ImageSharp/Formats/Heif/HeifConfigurationModule.cs rename src/ImageSharp/Formats/{Heic/HeicConstants.cs => Heif/HeifConstants.cs} (70%) rename src/ImageSharp/Formats/{Heic/HeicDecoder.cs => Heif/HeifDecoder.cs} (76%) rename src/ImageSharp/Formats/{Heic/HeicDecoderCore.cs => Heif/HeifDecoderCore.cs} (79%) rename src/ImageSharp/Formats/{Heic/HeicEncoder.cs => Heif/HeifEncoder.cs} (55%) rename src/ImageSharp/Formats/{Heic/HeicEncoderCore.cs => Heif/HeifEncoderCore.cs} (82%) rename src/ImageSharp/Formats/{Heic/HeicFormat.cs => Heif/HeifFormat.cs} (57%) rename src/ImageSharp/Formats/{Heic/HeicImageFormatDetector.cs => Heif/HeifImageFormatDetector.cs} (63%) rename src/ImageSharp/Formats/{Heic/HeicItem.cs => Heif/HeifItem.cs} (89%) rename src/ImageSharp/Formats/{Heic/HeicItemLink.cs => Heif/HeifItemLink.cs} (67%) rename src/ImageSharp/Formats/{Heic/HeicLocation.cs => Heif/HeifLocation.cs} (69%) rename src/ImageSharp/Formats/{Heic/HeicMetadata.cs => Heif/HeifMetadata.cs} (50%) rename src/ImageSharp/Formats/{Heic => Heif}/IHeicEncoderOptions.cs (63%) rename src/ImageSharp/Formats/{Heic => Heif}/MetadataExtensions.cs (58%) rename src/ImageSharp/Formats/{Heic => Heif}/Readme.md (100%) rename tests/ImageSharp.Tests/Formats/{Heic/HeicDecoderTests.cs => Heif/HeifDecoderTests.cs} (51%) rename tests/ImageSharp.Tests/Formats/{Heic/HeicEncoderTests.cs => Heif/HeifEncoderTests.cs} (60%) rename tests/Images/External/ReferenceOutput/{HeicDecoderTests => HeifDecoderTests}/Decode_Rgba32_IMG-20230508-0053.png (100%) diff --git a/.gitattributes b/.gitattributes index 42194daa60..b5f742ab47 100644 --- a/.gitattributes +++ b/.gitattributes @@ -136,7 +136,3 @@ *.ico filter=lfs diff=lfs merge=lfs -text *.cur filter=lfs diff=lfs merge=lfs -text *.ani filter=lfs diff=lfs merge=lfs -text -*.heic filter=lfs diff=lfs merge=lfs -text -*.heif filter=lfs diff=lfs merge=lfs -text -*.hif filter=lfs diff=lfs merge=lfs -text -*.avif filter=lfs diff=lfs merge=lfs -text diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index 21ecd2cb2b..daf43edc35 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -5,7 +5,7 @@ using System.Collections.Concurrent; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; -using SixLabors.ImageSharp.Formats.Heic; +using SixLabors.ImageSharp.Formats.Heif; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.Formats.Png; @@ -212,7 +212,7 @@ public sealed class Configuration /// . /// . /// . - /// . + /// . /// /// The default configuration of . internal static Configuration CreateDefaultInstance() => new( @@ -225,5 +225,5 @@ public sealed class Configuration new TiffConfigurationModule(), new WebpConfigurationModule(), new QoiConfigurationModule(), - new HeicConfigurationModule()); + new HeifConfigurationModule()); } diff --git a/src/ImageSharp/Formats/Heic/HeicConfigurationModule.cs b/src/ImageSharp/Formats/Heic/HeicConfigurationModule.cs deleted file mode 100644 index 0ba7ceef67..0000000000 --- a/src/ImageSharp/Formats/Heic/HeicConfigurationModule.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -namespace SixLabors.ImageSharp.Formats.Heic; - -/// -/// Registers the image encoders, decoders and mime type detectors for the HEIC format. -/// -public sealed class HeicConfigurationModule : IImageFormatConfigurationModule -{ - /// - public void Configure(Configuration configuration) - { - configuration.ImageFormatsManager.SetEncoder(HeicFormat.Instance, new HeicEncoder()); - configuration.ImageFormatsManager.SetDecoder(HeicFormat.Instance, HeicDecoder.Instance); - configuration.ImageFormatsManager.AddImageFormatDetector(new HeicImageFormatDetector()); - } -} diff --git a/src/ImageSharp/Formats/Heic/Heic4CharCode.cs b/src/ImageSharp/Formats/Heif/Heif4CharCode.cs similarity index 96% rename from src/ImageSharp/Formats/Heic/Heic4CharCode.cs rename to src/ImageSharp/Formats/Heif/Heif4CharCode.cs index a64c94b686..2b14a62725 100644 --- a/src/ImageSharp/Formats/Heic/Heic4CharCode.cs +++ b/src/ImageSharp/Formats/Heif/Heif4CharCode.cs @@ -5,13 +5,13 @@ using System.CodeDom.Compiler; -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Supported 4 character codes for use in HEIC images. +/// Supported 4 character codes for use in HEIF images. /// [GeneratedCode("T4", "")] -public enum Heic4CharCode : uint +public enum Heif4CharCode : uint { /// /// File Type. diff --git a/src/ImageSharp/Formats/Heic/Heic4CharCode.tt b/src/ImageSharp/Formats/Heif/Heif4CharCode.tt similarity index 94% rename from src/ImageSharp/Formats/Heic/Heic4CharCode.tt rename to src/ImageSharp/Formats/Heif/Heif4CharCode.tt index 61ceb332ac..6f15a33ab9 100644 --- a/src/ImageSharp/Formats/Heic/Heic4CharCode.tt +++ b/src/ImageSharp/Formats/Heif/Heif4CharCode.tt @@ -59,13 +59,13 @@ using System.CodeDom.Compiler; -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Supported 4 character codes for use in HEIC images. +/// Supported 4 character codes for use in HEIF images. /// [GeneratedCode("T4", "")] -public enum Heic4CharCode : uint +public enum Heif4CharCode : uint { <# for (int i = 0; i < codes.Length; i += 2) diff --git a/src/ImageSharp/Formats/Heic/HeicCompressionMethod.cs b/src/ImageSharp/Formats/Heif/HeifCompressionMethod.cs similarity index 90% rename from src/ImageSharp/Formats/Heic/HeicCompressionMethod.cs rename to src/ImageSharp/Formats/Heif/HeifCompressionMethod.cs index efe826f85c..44d33d2393 100644 --- a/src/ImageSharp/Formats/Heic/HeicCompressionMethod.cs +++ b/src/ImageSharp/Formats/Heif/HeifCompressionMethod.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// /// Compression algorithms possible inside an HEIF (High Efficiency File Format) based file. /// -public enum HeicCompressionMethod +public enum HeifCompressionMethod { /// /// High Efficiency Video Coding diff --git a/src/ImageSharp/Formats/Heif/HeifConfigurationModule.cs b/src/ImageSharp/Formats/Heif/HeifConfigurationModule.cs new file mode 100644 index 0000000000..e08418bdb4 --- /dev/null +++ b/src/ImageSharp/Formats/Heif/HeifConfigurationModule.cs @@ -0,0 +1,18 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +namespace SixLabors.ImageSharp.Formats.Heif; + +/// +/// Registers the image encoders, decoders and mime type detectors for the HEIF format. +/// +public sealed class HeifConfigurationModule : IImageFormatConfigurationModule +{ + /// + public void Configure(Configuration configuration) + { + configuration.ImageFormatsManager.SetEncoder(HeifFormat.Instance, new HeifEncoder()); + configuration.ImageFormatsManager.SetDecoder(HeifFormat.Instance, HeifDecoder.Instance); + configuration.ImageFormatsManager.AddImageFormatDetector(new HeifImageFormatDetector()); + } +} diff --git a/src/ImageSharp/Formats/Heic/HeicConstants.cs b/src/ImageSharp/Formats/Heif/HeifConstants.cs similarity index 70% rename from src/ImageSharp/Formats/Heic/HeicConstants.cs rename to src/ImageSharp/Formats/Heif/HeifConstants.cs index 03a394a9fb..5ef49053dd 100644 --- a/src/ImageSharp/Formats/Heic/HeicConstants.cs +++ b/src/ImageSharp/Formats/Heif/HeifConstants.cs @@ -1,14 +1,14 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Contains HEIC (and H.265) constant values defined in the specification. +/// Contains HEIF constant values defined in the specification. /// -internal static class HeicConstants +internal static class HeifConstants { - public const Heic4CharCode HeicBrand = Heic4CharCode.heic; + public const Heif4CharCode HeicBrand = Heif4CharCode.heic; /// /// The list of mimetypes that equate to a HEIC. diff --git a/src/ImageSharp/Formats/Heic/HeicDecoder.cs b/src/ImageSharp/Formats/Heif/HeifDecoder.cs similarity index 76% rename from src/ImageSharp/Formats/Heic/HeicDecoder.cs rename to src/ImageSharp/Formats/Heif/HeifDecoder.cs index 9fd200575c..c1d79b1096 100644 --- a/src/ImageSharp/Formats/Heic/HeicDecoder.cs +++ b/src/ImageSharp/Formats/Heif/HeifDecoder.cs @@ -3,21 +3,21 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Image decoder for reading HEIC images from a stream. +/// Image decoder for reading HEIF images from a stream. /// -public sealed class HeicDecoder : ImageDecoder +public sealed class HeifDecoder : ImageDecoder { - private HeicDecoder() + private HeifDecoder() { } /// /// Gets the shared instance. /// - public static HeicDecoder Instance { get; } = new(); + public static HeifDecoder Instance { get; } = new(); /// protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) @@ -25,7 +25,7 @@ public sealed class HeicDecoder : ImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new HeicDecoderCore(options).Identify(options.Configuration, stream, cancellationToken); + return new HeifDecoderCore(options).Identify(options.Configuration, stream, cancellationToken); } /// @@ -34,7 +34,7 @@ public sealed class HeicDecoder : ImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - HeicDecoderCore decoder = new(options); + HeifDecoderCore decoder = new(options); Image image = decoder.Decode(options.Configuration, stream, cancellationToken); return image; diff --git a/src/ImageSharp/Formats/Heic/HeicDecoderCore.cs b/src/ImageSharp/Formats/Heif/HeifDecoderCore.cs similarity index 79% rename from src/ImageSharp/Formats/Heic/HeicDecoderCore.cs rename to src/ImageSharp/Formats/Heif/HeifDecoderCore.cs index ca6d2eb7a4..fb81a943c5 100644 --- a/src/ImageSharp/Formats/Heic/HeicDecoderCore.cs +++ b/src/ImageSharp/Formats/Heif/HeifDecoderCore.cs @@ -3,19 +3,18 @@ using System.Buffers; using System.Buffers.Binary; -using System.Globalization; using System.Text; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Performs the PBM decoding operation. +/// Performs the HEIF decoding operation. /// -internal sealed class HeicDecoderCore : IImageDecoderInternals +internal sealed class HeifDecoderCore : IImageDecoderInternals { /// /// The general configuration. @@ -29,23 +28,23 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals private uint primaryItem; - private readonly List items; + private readonly List items; - private readonly List itemLinks; + private readonly List itemLinks; private readonly byte[] buffer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The decoder options. - public HeicDecoderCore(DecoderOptions options) + public HeifDecoderCore(DecoderOptions options) { this.Options = options; this.configuration = options.Configuration; this.metadata = new ImageMetadata(); - this.items = new List(); - this.itemLinks = new List(); + this.items = new List(); + this.itemLinks = new List(); this.buffer = new byte[80]; } @@ -61,23 +60,23 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals { if (!this.CheckFileTypeBox(stream)) { - throw new ImageFormatException("Not an HEIC image."); + throw new ImageFormatException("Not an HEIF image."); } Image? image = null; while (stream.Position < stream.Length) { - long boxLength = this.ReadBoxHeader(stream, out Heic4CharCode boxType); + long boxLength = this.ReadBoxHeader(stream, out Heif4CharCode boxType); EnsureBoxBoundary(boxLength, stream); switch (boxType) { - case Heic4CharCode.meta: + case Heif4CharCode.meta: this.ParseMetadata(stream, boxLength); break; - case Heic4CharCode.mdat: + case Heif4CharCode.mdat: image = this.ParseMediaData(stream, boxLength); break; - case Heic4CharCode.free: + case Heif4CharCode.free: SkipBox(stream, boxLength); break; case 0U: @@ -89,7 +88,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals } } - HeicItem? item = this.FindItemById(this.primaryItem); + HeifItem? item = this.FindItemById(this.primaryItem); if (item == null) { throw new ImageFormatException("No primary item found"); @@ -100,6 +99,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals throw new NotImplementedException("No JPEG image decoded"); } + this.UpdateMetadata(image.Metadata, item); return image; } @@ -110,11 +110,11 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals while (stream.Position < stream.Length) { - long boxLength = this.ReadBoxHeader(stream, out Heic4CharCode boxType); + long boxLength = this.ReadBoxHeader(stream, out Heif4CharCode boxType); EnsureBoxBoundary(boxLength, stream); switch (boxType) { - case Heic4CharCode.meta: + case Heif4CharCode.meta: this.ParseMetadata(stream, boxLength); break; default: @@ -124,40 +124,45 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals } } - HeicItem? item = this.FindItemById(this.primaryItem); + HeifItem? item = this.FindItemById(this.primaryItem); if (item == null) { throw new ImageFormatException("No primary item found"); } - HeicMetadata meta = this.metadata.GetHeicMetadata(); - HeicCompressionMethod compressionMethod = HeicCompressionMethod.Hevc; - if (item.Type == Heic4CharCode.av01) - { - compressionMethod = HeicCompressionMethod.Av1; - } - else if (this.itemLinks.Any(link => link.Type == Heic4CharCode.thmb)) - { - compressionMethod = HeicCompressionMethod.LegacyJpeg; - } - - meta.CompressionMethod = compressionMethod; + this.UpdateMetadata(this.metadata, item); return new ImageInfo(new PixelTypeInfo(item.BitsPerPixel), new(item.Extent.Width, item.Extent.Height), this.metadata); } private bool CheckFileTypeBox(BufferedReadStream stream) { - long boxLength = this.ReadBoxHeader(stream, out Heic4CharCode boxType); + long boxLength = this.ReadBoxHeader(stream, out Heif4CharCode boxType); Span buffer = this.ReadIntoBuffer(stream, boxLength); uint majorBrand = BinaryPrimitives.ReadUInt32BigEndian(buffer); - bool correctBrand = majorBrand == (uint)Heic4CharCode.heic || majorBrand == (uint)Heic4CharCode.heix; + bool correctBrand = majorBrand is (uint)Heif4CharCode.heic or (uint)Heif4CharCode.heix or (uint)Heif4CharCode.avif; // TODO: Interpret minorVersion and compatible brands. - return boxType == Heic4CharCode.ftyp && correctBrand; + return boxType == Heif4CharCode.ftyp && correctBrand; + } + + private void UpdateMetadata(ImageMetadata metadata, HeifItem item) + { + HeifMetadata meta = metadata.GetHeifMetadata(); + HeifCompressionMethod compressionMethod = HeifCompressionMethod.Hevc; + if (item.Type == Heif4CharCode.av01) + { + compressionMethod = HeifCompressionMethod.Av1; + } + else if (item.Type == Heif4CharCode.jpeg || this.itemLinks.Any(link => link.Type == Heif4CharCode.thmb)) + { + compressionMethod = HeifCompressionMethod.LegacyJpeg; + } + + meta.CompressionMethod = compressionMethod; } - private long ReadBoxHeader(BufferedReadStream stream, out Heic4CharCode boxType) + private long ReadBoxHeader(BufferedReadStream stream, out Heif4CharCode boxType) { // Read 4 bytes of length of box Span buf = this.ReadIntoBuffer(stream, 8); @@ -165,7 +170,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals long headerSize = 8; // Read 4 bytes of box type - boxType = (Heic4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buf[4..]); + boxType = (Heif4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buf[4..]); if (boxSize == 1) { @@ -177,11 +182,11 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals return boxSize - headerSize; } - private static int ParseBoxHeader(Span buffer, out long length, out Heic4CharCode boxType) + private static int ParseBoxHeader(Span buffer, out long length, out Heif4CharCode boxType) { long boxSize = BinaryPrimitives.ReadUInt32BigEndian(buffer); int bytesRead = 4; - boxType = (Heic4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer[bytesRead..]); + boxType = (Heif4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer[bytesRead..]); bytesRead += 4; if (boxSize == 1) { @@ -199,34 +204,34 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals stream.Skip(4); while (stream.Position < endPosition) { - long length = this.ReadBoxHeader(stream, out Heic4CharCode boxType); + long length = this.ReadBoxHeader(stream, out Heif4CharCode boxType); EnsureBoxBoundary(length, boxLength); switch (boxType) { - case Heic4CharCode.iprp: + case Heif4CharCode.iprp: this.ParseItemProperties(stream, length); break; - case Heic4CharCode.iinf: + case Heif4CharCode.iinf: this.ParseItemInfo(stream, length); break; - case Heic4CharCode.iref: + case Heif4CharCode.iref: this.ParseItemReference(stream, length); break; - case Heic4CharCode.pitm: + case Heif4CharCode.pitm: this.ParsePrimaryItem(stream, length); break; - case Heic4CharCode.hdlr: + case Heif4CharCode.hdlr: this.ParseHandler(stream, length); break; - case Heic4CharCode.iloc: + case Heif4CharCode.iloc: this.ParseItemLocation(stream, length); break; - case Heic4CharCode.dinf: - case Heic4CharCode.idat: - case Heic4CharCode.grpl: - case Heic4CharCode.ipro: - case Heic4CharCode.uuid: - case Heic4CharCode.ipmc: + case Heif4CharCode.dinf: + case Heif4CharCode.idat: + case Heif4CharCode.grpl: + case Heif4CharCode.ipro: + case Heif4CharCode.uuid: + case Heif4CharCode.ipmc: // Silently skip these boxes. SkipBox(stream, length); break; @@ -242,8 +247,8 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals // Only read the handler type, to check if this is not a movie file. int bytesRead = 8; - Heic4CharCode handlerType = (Heic4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer[bytesRead..]); - if (handlerType != Heic4CharCode.pict) + Heif4CharCode handlerType = (Heif4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer[bytesRead..]); + if (handlerType != Heif4CharCode.pict) { throw new ImageFormatException("Not a picture file."); } @@ -266,15 +271,15 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals private int ParseItemInfoEntry(Span buffer) { - int bytesRead = ParseBoxHeader(buffer, out long boxLength, out Heic4CharCode boxType); + int bytesRead = ParseBoxHeader(buffer, out long boxLength, out Heif4CharCode boxType); byte version = buffer[bytesRead]; bytesRead += 4; - HeicItem? item = null; + HeifItem? item = null; if (version is 0 or 1) { uint itemId = BinaryPrimitives.ReadUInt16BigEndian(buffer[bytesRead..]); bytesRead += 2; - item = new HeicItem(boxType, itemId); + item = new HeifItem(boxType, itemId); // Skip Protection Index, not sure what that means... bytesRead += 2; @@ -312,12 +317,12 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals // Skip Protection Index, not sure what that means... bytesRead += 2; - Heic4CharCode itemType = (Heic4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer[bytesRead..]); + Heif4CharCode itemType = (Heif4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer[bytesRead..]); bytesRead += 4; - item = new HeicItem(itemType, itemId); + item = new HeifItem(itemType, itemId); item.Name = ReadNullTerminatedString(buffer[bytesRead..]); bytesRead += item.Name.Length + 1; - if (item.Type == Heic4CharCode.mime) + if (item.Type == Heif4CharCode.mime) { item.ContentType = ReadNullTerminatedString(buffer[bytesRead..]); bytesRead += item.ContentType.Length + 1; @@ -329,7 +334,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals bytesRead += item.ContentEncoding.Length + 1; } } - else if (item.Type == Heic4CharCode.uri) + else if (item.Type == Heif4CharCode.uri) { item.UriType = ReadNullTerminatedString(buffer[bytesRead..]); bytesRead += item.UriType.Length + 1; @@ -352,9 +357,9 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals bytesRead += 4; while (bytesRead < boxLength) { - bytesRead += ParseBoxHeader(buffer[bytesRead..], out long subBoxLength, out Heic4CharCode linkType); + bytesRead += ParseBoxHeader(buffer[bytesRead..], out long subBoxLength, out Heif4CharCode linkType); uint sourceId = ReadUInt16Or32(buffer, largeIds, ref bytesRead); - HeicItemLink link = new(linkType, sourceId); + HeifItemLink link = new(linkType, sourceId); int count = BinaryPrimitives.ReadUInt16BigEndian(buffer[bytesRead..]); bytesRead += 2; @@ -380,18 +385,18 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals private void ParseItemProperties(BufferedReadStream stream, long boxLength) { // Cannot use Dictionary here, Properties can have multiple instances with the same key. - List> properties = new(); + List> properties = new(); long endBoxPosition = stream.Position + boxLength; while (stream.Position < endBoxPosition) { - long containerLength = this.ReadBoxHeader(stream, out Heic4CharCode containerType); + long containerLength = this.ReadBoxHeader(stream, out Heif4CharCode containerType); EnsureBoxBoundary(containerLength, boxLength); - if (containerType == Heic4CharCode.ipco) + if (containerType == Heif4CharCode.ipco) { // Parse Item Property Container, which is just an array of property boxes. this.ParsePropertyContainer(stream, containerLength, properties); } - else if (containerType == Heic4CharCode.ipma) + else if (containerType == Heif4CharCode.ipma) { // Parse Item Property Association this.ParsePropertyAssociation(stream, containerLength, properties); @@ -403,28 +408,28 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals } } - private void ParsePropertyContainer(BufferedReadStream stream, long boxLength, List> properties) + private void ParsePropertyContainer(BufferedReadStream stream, long boxLength, List> properties) { long endPosition = stream.Position + boxLength; while (stream.Position < endPosition) { - int itemLength = (int)this.ReadBoxHeader(stream, out Heic4CharCode itemType); + int itemLength = (int)this.ReadBoxHeader(stream, out Heif4CharCode itemType); EnsureBoxBoundary(itemLength, boxLength); Span buffer = this.ReadIntoBuffer(stream, itemLength); switch (itemType) { - case Heic4CharCode.ispe: + case Heif4CharCode.ispe: // Skip over version (8 bits) and flags (24 bits). int width = (int)BinaryPrimitives.ReadUInt32BigEndian(buffer[4..]); int height = (int)BinaryPrimitives.ReadUInt32BigEndian(buffer[8..]); - properties.Add(new KeyValuePair(Heic4CharCode.ispe, new Size(width, height))); + properties.Add(new KeyValuePair(Heif4CharCode.ispe, new Size(width, height))); break; - case Heic4CharCode.pasp: + case Heif4CharCode.pasp: int horizontalSpacing = (int)BinaryPrimitives.ReadUInt32BigEndian(buffer); int verticalSpacing = (int)BinaryPrimitives.ReadUInt32BigEndian(buffer[4..]); - properties.Add(new KeyValuePair(Heic4CharCode.pasp, new Size(horizontalSpacing, verticalSpacing))); + properties.Add(new KeyValuePair(Heif4CharCode.pasp, new Size(horizontalSpacing, verticalSpacing))); break; - case Heic4CharCode.pixi: + case Heif4CharCode.pixi: // Skip over version (8 bits) and flags (24 bits). int channelCount = buffer[4]; int offset = 5; @@ -434,20 +439,20 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals bitsPerPixel += buffer[offset + i]; } - properties.Add(new KeyValuePair(Heic4CharCode.pixi, new int[] { channelCount, bitsPerPixel })); + properties.Add(new KeyValuePair(Heif4CharCode.pixi, new int[] { channelCount, bitsPerPixel })); break; - case Heic4CharCode.altt: - case Heic4CharCode.colr: - case Heic4CharCode.imir: - case Heic4CharCode.irot: - case Heic4CharCode.iscl: - case Heic4CharCode.hvcC: - case Heic4CharCode.av1C: - case Heic4CharCode.rloc: - case Heic4CharCode.udes: + case Heif4CharCode.altt: + case Heif4CharCode.colr: + case Heif4CharCode.imir: + case Heif4CharCode.irot: + case Heif4CharCode.iscl: + case Heif4CharCode.hvcC: + case Heif4CharCode.av1C: + case Heif4CharCode.rloc: + case Heif4CharCode.udes: // TODO: Implement - properties.Add(new KeyValuePair(itemType, new object())); + properties.Add(new KeyValuePair(itemType, new object())); break; default: throw new ImageFormatException($"Unknown item type in property box of '{PrettyPrint(itemType)}'"); @@ -455,7 +460,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals } } - private void ParsePropertyAssociation(BufferedReadStream stream, long boxLength, List> properties) + private void ParsePropertyAssociation(BufferedReadStream stream, long boxLength, List> properties) { Span buffer = this.ReadIntoBuffer(stream, boxLength); byte version = buffer[0]; @@ -477,16 +482,16 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals propId = buffer[bytesRead++] & 0x4FU; } - KeyValuePair prop = properties[(int)propId]; + KeyValuePair prop = properties[(int)propId]; switch (prop.Key) { - case Heic4CharCode.ispe: + case Heif4CharCode.ispe: this.items[itemId].SetExtent((Size)prop.Value); break; - case Heic4CharCode.pasp: + case Heif4CharCode.pasp: this.items[itemId].PixelAspectRatio = (Size)prop.Value; break; - case Heic4CharCode.pixi: + case Heif4CharCode.pixi: int[] values = (int[])prop.Value; this.items[itemId].ChannelCount = values[0]; this.items[itemId].BitsPerPixel = values[1]; @@ -516,7 +521,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals for (uint i = 0; i < itemCount; i++) { uint itemId = ReadUInt16Or32(buffer, version == 2, ref bytesRead); - HeicItem? item = this.FindItemById(itemId); + HeifItem? item = this.FindItemById(itemId); if (version is 1 or 2) { bytesRead++; @@ -538,7 +543,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals ulong extentOffset = ReadUIntVariable(buffer, offsetSize, ref bytesRead); ulong extentLength = ReadUIntVariable(buffer, lengthSize, ref bytesRead); - HeicLocation loc = new HeicLocation((long)extentOffset, (long)extentLength); + HeifLocation loc = new HeifLocation((long)extentOffset, (long)extentLength); item?.DataLocations.Add(loc); } } @@ -591,14 +596,14 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals where TPixel : unmanaged, IPixel { // FIXME: No HVC decoding yet, so parse only a JPEG thumbnail. - HeicItemLink? thumbLink = this.itemLinks.FirstOrDefault(link => link.Type == Heic4CharCode.thmb); + HeifItemLink? thumbLink = this.itemLinks.FirstOrDefault(link => link.Type == Heif4CharCode.thmb); if (thumbLink == null) { throw new NotImplementedException("No thumbnail found"); } - HeicItem? thumbItem = this.FindItemById(thumbLink.SourceId); - if (thumbItem == null || thumbItem.Type != Heic4CharCode.jpeg) + HeifItem? thumbItem = this.FindItemById(thumbLink.SourceId); + if (thumbItem == null || thumbItem.Type != Heif4CharCode.jpeg) { throw new NotImplementedException("No HVC decoding implemented yet"); } @@ -610,8 +615,8 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals Span thumbSpan = thumbMemory.GetSpan(); stream.Read(thumbSpan); - HeicMetadata meta = this.metadata.GetHeicMetadata(); - meta.CompressionMethod = HeicCompressionMethod.LegacyJpeg; + HeifMetadata meta = this.metadata.GetHeifMetadata(); + meta.CompressionMethod = HeifCompressionMethod.LegacyJpeg; return Image.Load(thumbSpan); } @@ -645,7 +650,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals } } - private HeicItem? FindItemById(uint itemId) + private HeifItem? FindItemById(uint itemId) => this.items.FirstOrDefault(item => item.Id == itemId); private static string ReadNullTerminatedString(Span span) @@ -654,7 +659,7 @@ internal sealed class HeicDecoderCore : IImageDecoderInternals return Encoding.UTF8.GetString(bytes); } - private static string PrettyPrint(Heic4CharCode code) + private static string PrettyPrint(Heif4CharCode code) { string? pretty = Enum.GetName(code); if (string.IsNullOrEmpty(pretty)) diff --git a/src/ImageSharp/Formats/Heic/HeicEncoder.cs b/src/ImageSharp/Formats/Heif/HeifEncoder.cs similarity index 55% rename from src/ImageSharp/Formats/Heic/HeicEncoder.cs rename to src/ImageSharp/Formats/Heif/HeifEncoder.cs index 8579564ad1..170dc7bd72 100644 --- a/src/ImageSharp/Formats/Heic/HeicEncoder.cs +++ b/src/ImageSharp/Formats/Heif/HeifEncoder.cs @@ -1,19 +1,17 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using SixLabors.ImageSharp.Advanced; - -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Image encoder for writing an image to a stream as HEIC images. +/// Image encoder for writing an image to a stream as HEIF images. /// -public sealed class HeicEncoder : ImageEncoder +public sealed class HeifEncoder : ImageEncoder { /// protected override void Encode(Image image, Stream stream, CancellationToken cancellationToken) { - HeicEncoderCore encoder = new(image.Configuration, this); + HeifEncoderCore encoder = new(image.Configuration, this); encoder.Encode(image, stream, cancellationToken); } } diff --git a/src/ImageSharp/Formats/Heic/HeicEncoderCore.cs b/src/ImageSharp/Formats/Heif/HeifEncoderCore.cs similarity index 82% rename from src/ImageSharp/Formats/Heic/HeicEncoderCore.cs rename to src/ImageSharp/Formats/Heif/HeifEncoderCore.cs index ce2784da80..8f83d9c6d8 100644 --- a/src/ImageSharp/Formats/Heic/HeicEncoderCore.cs +++ b/src/ImageSharp/Formats/Heif/HeifEncoderCore.cs @@ -1,18 +1,17 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System; using System.Buffers.Binary; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Image encoder for writing an image to a stream as a HEIC image. +/// Image encoder for writing an image to a stream as a HEIF image. /// -internal sealed class HeicEncoderCore : IImageEncoderInternals +internal sealed class HeifEncoderCore : IImageEncoderInternals { /// /// The global configuration. @@ -22,14 +21,14 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals /// /// The encoder with options. /// - private readonly HeicEncoder encoder; + private readonly HeifEncoder encoder; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The configuration. /// The encoder with options. - public HeicEncoderCore(Configuration configuration, HeicEncoder encoder) + public HeifEncoderCore(Configuration configuration, HeifEncoder encoder) { this.configuration = configuration; this.encoder = encoder; @@ -49,8 +48,8 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals Guard.NotNull(stream, nameof(stream)); byte[] pixels = await CompressPixels(image, cancellationToken); - List items = new(); - List links = new(); + List items = new(); + List links = new(); GenerateItems(image, pixels, items, links); // Write out the generated header and pixels. @@ -58,25 +57,28 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals this.WriteMetadataBox(items, links, stream); this.WriteMediaDataBox(pixels, stream); stream.Flush(); + + HeifMetadata meta = image.Metadata.GetHeifMetadata(); + meta.CompressionMethod = HeifCompressionMethod.LegacyJpeg; } - private static void GenerateItems(Image image, byte[] pixels, List items, List links) + private static void GenerateItems(Image image, byte[] pixels, List items, List links) where TPixel : unmanaged, IPixel { - HeicItem primaryItem = new(Heic4CharCode.jpeg, 1u); - primaryItem.DataLocations.Add(new HeicLocation(0L, pixels.LongLength)); + HeifItem primaryItem = new(Heif4CharCode.jpeg, 1u); + primaryItem.DataLocations.Add(new HeifLocation(0L, pixels.LongLength)); primaryItem.BitsPerPixel = 24; primaryItem.ChannelCount = 3; primaryItem.SetExtent(image.Size); items.Add(primaryItem); // Create a fake thumbnail, to make our own Decoder happy. - HeicItemLink thumbnail = new(Heic4CharCode.thmb, 1u); + HeifItemLink thumbnail = new(Heif4CharCode.thmb, 1u); thumbnail.DestinationIds.Add(1u); links.Add(thumbnail); } - private static int WriteBoxHeader(Span buffer, Heic4CharCode type) + private static int WriteBoxHeader(Span buffer, Heif4CharCode type) { int bytesWritten = 0; BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], 8U); @@ -87,7 +89,7 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals return bytesWritten; } - private static int WriteBoxHeader(Span buffer, Heic4CharCode type, byte version, uint flags) + private static int WriteBoxHeader(Span buffer, Heif4CharCode type, byte version, uint flags) { int bytesWritten = 0; BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], 12); @@ -106,25 +108,25 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals private void WriteFileTypeBox(Stream stream) { Span buffer = stackalloc byte[24]; - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.ftyp); - BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heic4CharCode.heic); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.ftyp); + BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heif4CharCode.heic); bytesWritten += 4; BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], 0); bytesWritten += 4; - BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heic4CharCode.mif1); + BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heif4CharCode.mif1); bytesWritten += 4; - BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heic4CharCode.heic); + BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heif4CharCode.heic); bytesWritten += 4; BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)bytesWritten); stream.Write(buffer); } - private void WriteMetadataBox(List items, List links, Stream stream) + private void WriteMetadataBox(List items, List links, Stream stream) { using AutoExpandingMemory memory = new(this.configuration, 0x1000); Span buffer = memory.GetSpan(12); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.meta, 0, 0); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.meta, 0, 0); bytesWritten += WriteHandlerBox(memory, bytesWritten); bytesWritten += WritePrimaryItemBox(memory, bytesWritten); bytesWritten += WriteItemInfoBox(memory, bytesWritten, items); @@ -141,10 +143,10 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals private static int WriteHandlerBox(AutoExpandingMemory memory, int memoryOffset) { Span buffer = memory.GetSpan(memoryOffset, 33); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.hdlr, 0, 0); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.hdlr, 0, 0); BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], 0); bytesWritten += 4; - BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heic4CharCode.pict); + BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)Heif4CharCode.pict); bytesWritten += 4; for (int i = 0; i < 13; i++) { @@ -158,7 +160,7 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals private static int WritePrimaryItemBox(AutoExpandingMemory memory, int memoryOffset) { Span buffer = memory.GetSpan(memoryOffset, 14); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.pitm, 0, 0); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.pitm, 0, 0); BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], 1); bytesWritten += 2; @@ -166,16 +168,16 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals return bytesWritten; } - private static int WriteItemInfoBox(AutoExpandingMemory memory, int memoryOffset, List items) + private static int WriteItemInfoBox(AutoExpandingMemory memory, int memoryOffset, List items) { Span buffer = memory.GetSpan(memoryOffset, 14 + (items.Count * 21)); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.iinf, 0, 0); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.iinf, 0, 0); BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], (ushort)items.Count); bytesWritten += 2; - foreach (HeicItem item in items) + foreach (HeifItem item in items) { int itemLengthOffset = bytesWritten; - bytesWritten += WriteBoxHeader(buffer[bytesWritten..], Heic4CharCode.infe, 2, 0); + bytesWritten += WriteBoxHeader(buffer[bytesWritten..], Heif4CharCode.infe, 2, 0); BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], (ushort)item.Id); bytesWritten += 2; BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], 0); @@ -191,11 +193,11 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals return bytesWritten; } - private static int WriteItemReferenceBox(AutoExpandingMemory memory, int memoryOffset, List items, List links) + private static int WriteItemReferenceBox(AutoExpandingMemory memory, int memoryOffset, List items, List links) { Span buffer = memory.GetSpan(memoryOffset, 12 + (links.Count * (12 + (items.Count * 2)))); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.iref, 0, 0); - foreach (HeicItemLink link in links) + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.iref, 0, 0); + foreach (HeifItemLink link in links) { int itemLengthOffset = bytesWritten; bytesWritten += WriteBoxHeader(buffer[bytesWritten..], link.Type); @@ -216,16 +218,16 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals return bytesWritten; } - private static int WriteItemPropertiesBox(AutoExpandingMemory memory, int memoryOffset, List items) + private static int WriteItemPropertiesBox(AutoExpandingMemory memory, int memoryOffset, List items) { const ushort numPropPerItem = 1; Span buffer = memory.GetSpan(memoryOffset, 20); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.iprp); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.iprp); // Write 'ipco' box int ipcoLengthOffset = bytesWritten; - bytesWritten += WriteBoxHeader(buffer[bytesWritten..], Heic4CharCode.ipco); - foreach (HeicItem item in items) + bytesWritten += WriteBoxHeader(buffer[bytesWritten..], Heif4CharCode.ipco); + foreach (HeifItem item in items) { bytesWritten += WriteSpatialExtentPropertyBox(memory, memoryOffset + bytesWritten, item); } @@ -235,11 +237,11 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals // Write 'ipma' box int ipmaLengthOffset = bytesWritten; - bytesWritten += WriteBoxHeader(buffer[bytesWritten..], Heic4CharCode.ipma, 0, 0); + bytesWritten += WriteBoxHeader(buffer[bytesWritten..], Heif4CharCode.ipma, 0, 0); BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)(items.Count * numPropPerItem)); bytesWritten += 4; ushort propIndex = 0; - foreach (HeicItem item in items) + foreach (HeifItem item in items) { BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], (ushort)item.Id); bytesWritten += 2; @@ -256,10 +258,10 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals return bytesWritten; } - private static int WriteSpatialExtentPropertyBox(AutoExpandingMemory memory, int memoryOffset, HeicItem item) + private static int WriteSpatialExtentPropertyBox(AutoExpandingMemory memory, int memoryOffset, HeifItem item) { Span buffer = memory.GetSpan(memoryOffset, 20); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.ispe, 0, 0); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.ispe, 0, 0); BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)item.Extent.Width); bytesWritten += 4; BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)item.Extent.Height); @@ -272,16 +274,16 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals private static int WriteItemDataBox(AutoExpandingMemory memory, int memoryOffset) { Span buffer = memory.GetSpan(memoryOffset, 10); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.idat); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.idat); BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)bytesWritten); return bytesWritten; } - private static int WriteItemLocationBox(AutoExpandingMemory memory, int memoryOffset, List items) + private static int WriteItemLocationBox(AutoExpandingMemory memory, int memoryOffset, List items) { Span buffer = memory.GetSpan(memoryOffset, 30 + (items.Count * 8)); - int bytesWritten = WriteBoxHeader(buffer, Heic4CharCode.iloc, 1, 0); + int bytesWritten = WriteBoxHeader(buffer, Heif4CharCode.iloc, 1, 0); buffer[bytesWritten++] = 0x44; buffer[bytesWritten++] = 0; BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], 1); @@ -293,10 +295,10 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals buffer[bytesWritten++] = 0; } - IEnumerable itemLocs = items.SelectMany(item => item.DataLocations).Where(loc => loc != null); + IEnumerable itemLocs = items.SelectMany(item => item.DataLocations).Where(loc => loc != null); BinaryPrimitives.WriteUInt16BigEndian(buffer[bytesWritten..], (ushort)itemLocs.Count()); bytesWritten += 2; - foreach (HeicLocation loc in itemLocs) + foreach (HeifLocation loc in itemLocs) { BinaryPrimitives.WriteUInt32BigEndian(buffer[bytesWritten..], (uint)loc.Offset); bytesWritten += 4; @@ -311,7 +313,7 @@ internal sealed class HeicEncoderCore : IImageEncoderInternals private void WriteMediaDataBox(Span data, Stream stream) { Span buf = stackalloc byte[12]; - int bytesWritten = WriteBoxHeader(buf, Heic4CharCode.mdat); + int bytesWritten = WriteBoxHeader(buf, Heif4CharCode.mdat); BinaryPrimitives.WriteUInt32BigEndian(buf, (uint)(data.Length + bytesWritten)); stream.Write(buf[..bytesWritten]); diff --git a/src/ImageSharp/Formats/Heic/HeicFormat.cs b/src/ImageSharp/Formats/Heif/HeifFormat.cs similarity index 57% rename from src/ImageSharp/Formats/Heic/HeicFormat.cs rename to src/ImageSharp/Formats/Heif/HeifFormat.cs index be47afce00..3a6f23ecb6 100644 --- a/src/ImageSharp/Formats/Heic/HeicFormat.cs +++ b/src/ImageSharp/Formats/Heif/HeifFormat.cs @@ -1,21 +1,21 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// /// Registers the image encoders, decoders and mime type detectors for the HEIC format. /// -public sealed class HeicFormat : IImageFormat +public sealed class HeifFormat : IImageFormat { - private HeicFormat() + private HeifFormat() { } /// /// Gets the shared instance. /// - public static HeicFormat Instance { get; } = new(); + public static HeifFormat Instance { get; } = new(); /// public string Name => "HEIC"; @@ -24,11 +24,11 @@ public sealed class HeicFormat : IImageFormat public string DefaultMimeType => "image/heif"; /// - public IEnumerable MimeTypes => HeicConstants.MimeTypes; + public IEnumerable MimeTypes => HeifConstants.MimeTypes; /// - public IEnumerable FileExtensions => HeicConstants.FileExtensions; + public IEnumerable FileExtensions => HeifConstants.FileExtensions; /// - public HeicMetadata CreateDefaultFormatMetadata() => new(); + public HeifMetadata CreateDefaultFormatMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Heic/HeicImageFormatDetector.cs b/src/ImageSharp/Formats/Heif/HeifImageFormatDetector.cs similarity index 63% rename from src/ImageSharp/Formats/Heic/HeicImageFormatDetector.cs rename to src/ImageSharp/Formats/Heif/HeifImageFormatDetector.cs index 93aefca223..10dfa86158 100644 --- a/src/ImageSharp/Formats/Heic/HeicImageFormatDetector.cs +++ b/src/ImageSharp/Formats/Heif/HeifImageFormatDetector.cs @@ -4,12 +4,12 @@ using System.Buffers.Binary; using System.Diagnostics.CodeAnalysis; -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Detects HEIC file headers. +/// Detects HEIF file headers. /// -public sealed class HeicImageFormatDetector : IImageFormatDetector +public sealed class HeifImageFormatDetector : IImageFormatDetector { /// public int HeaderSize => 12; @@ -17,14 +17,14 @@ public sealed class HeicImageFormatDetector : IImageFormatDetector /// public bool TryDetectFormat(ReadOnlySpan header, [NotNullWhen(true)] out IImageFormat? format) { - format = IsSupportedFileFormat(header) ? HeicFormat.Instance : null; + format = IsSupportedFileFormat(header) ? HeifFormat.Instance : null; return format != null; } private static bool IsSupportedFileFormat(ReadOnlySpan header) { - bool hasFtyp = BinaryPrimitives.ReadUInt32BigEndian(header.Slice(4)) == (uint)Heic4CharCode.ftyp; + bool hasFtyp = BinaryPrimitives.ReadUInt32BigEndian(header.Slice(4)) == (uint)Heif4CharCode.ftyp; uint brand = BinaryPrimitives.ReadUInt32BigEndian(header.Slice(8)); - return hasFtyp && (brand == (uint)Heic4CharCode.heic || brand == (uint)Heic4CharCode.heix || brand == (uint)Heic4CharCode.avif); + return hasFtyp && (brand == (uint)Heif4CharCode.heic || brand == (uint)Heif4CharCode.heix || brand == (uint)Heif4CharCode.avif); } } diff --git a/src/ImageSharp/Formats/Heic/HeicItem.cs b/src/ImageSharp/Formats/Heif/HeifItem.cs similarity index 89% rename from src/ImageSharp/Formats/Heic/HeicItem.cs rename to src/ImageSharp/Formats/Heif/HeifItem.cs index 4127aebb01..60f26df3ff 100644 --- a/src/ImageSharp/Formats/Heic/HeicItem.cs +++ b/src/ImageSharp/Formats/Heif/HeifItem.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Provides definition for a HEIC Item. +/// Provides definition for a HEIF Item. /// -public class HeicItem(Heic4CharCode type, uint id) +public class HeifItem(Heif4CharCode type, uint id) { /// /// Gets the ID of this Item. @@ -16,7 +16,7 @@ public class HeicItem(Heic4CharCode type, uint id) /// /// Gets the type of this Item. /// - public Heic4CharCode Type { get; } = type; + public Heif4CharCode Type { get; } = type; /// /// Gets or sets the name of this item. @@ -71,7 +71,7 @@ public class HeicItem(Heic4CharCode type, uint id) /// /// Gets the list of data locations for this item. /// - public List DataLocations { get; } = new List(); + public List DataLocations { get; } = new List(); /// /// Set the image extent. diff --git a/src/ImageSharp/Formats/Heic/HeicItemLink.cs b/src/ImageSharp/Formats/Heif/HeifItemLink.cs similarity index 67% rename from src/ImageSharp/Formats/Heic/HeicItemLink.cs rename to src/ImageSharp/Formats/Heif/HeifItemLink.cs index da1578fcfa..95e84a237f 100644 --- a/src/ImageSharp/Formats/Heic/HeicItemLink.cs +++ b/src/ImageSharp/Formats/Heif/HeifItemLink.cs @@ -1,17 +1,17 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Link between instances within the same HEIC file. +/// Link between instances within the same HEIF file. /// -public class HeicItemLink(Heic4CharCode type, uint sourceId) +public class HeifItemLink(Heif4CharCode type, uint sourceId) { /// /// Gets the type of link. /// - public Heic4CharCode Type { get; } = type; + public Heif4CharCode Type { get; } = type; /// /// Gets the ID of the source item of this link. diff --git a/src/ImageSharp/Formats/Heic/HeicLocation.cs b/src/ImageSharp/Formats/Heif/HeifLocation.cs similarity index 69% rename from src/ImageSharp/Formats/Heic/HeicLocation.cs rename to src/ImageSharp/Formats/Heif/HeifLocation.cs index 7a342656e3..9348ba981e 100644 --- a/src/ImageSharp/Formats/Heic/HeicLocation.cs +++ b/src/ImageSharp/Formats/Heif/HeifLocation.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Location within the file of an . +/// Location within the file of an . /// -public class HeicLocation(long offset, long length) +public class HeifLocation(long offset, long length) { /// /// Gets the file offset of this location. diff --git a/src/ImageSharp/Formats/Heic/HeicMetadata.cs b/src/ImageSharp/Formats/Heif/HeifMetadata.cs similarity index 50% rename from src/ImageSharp/Formats/Heic/HeicMetadata.cs rename to src/ImageSharp/Formats/Heif/HeifMetadata.cs index f6f95a86cd..725389f0e5 100644 --- a/src/ImageSharp/Formats/Heic/HeicMetadata.cs +++ b/src/ImageSharp/Formats/Heif/HeifMetadata.cs @@ -1,32 +1,32 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Provides HEIC specific metadata information for the image. +/// Provides HEIF specific metadata information for the image. /// -public class HeicMetadata : IDeepCloneable +public class HeifMetadata : IDeepCloneable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public HeicMetadata() + public HeifMetadata() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The metadata to create an instance from. - private HeicMetadata(HeicMetadata other) + private HeifMetadata(HeifMetadata other) => this.CompressionMethod = other.CompressionMethod; /// /// Gets or sets the compression method used for the primary frame. /// - public HeicCompressionMethod CompressionMethod { get; set; } + public HeifCompressionMethod CompressionMethod { get; set; } /// - public IDeepCloneable DeepClone() => new HeicMetadata(this); + public IDeepCloneable DeepClone() => new HeifMetadata(this); } diff --git a/src/ImageSharp/Formats/Heic/IHeicEncoderOptions.cs b/src/ImageSharp/Formats/Heif/IHeicEncoderOptions.cs similarity index 63% rename from src/ImageSharp/Formats/Heic/IHeicEncoderOptions.cs rename to src/ImageSharp/Formats/Heif/IHeicEncoderOptions.cs index fb73ae3ab2..c3bde13730 100644 --- a/src/ImageSharp/Formats/Heic/IHeicEncoderOptions.cs +++ b/src/ImageSharp/Formats/Heif/IHeicEncoderOptions.cs @@ -1,10 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace SixLabors.ImageSharp.Formats.Heic; +namespace SixLabors.ImageSharp.Formats.Heif; /// -/// Configuration options for use during HEIC encoding. +/// Configuration options for use during HEIF encoding. /// internal interface IHeicEncoderOptions { diff --git a/src/ImageSharp/Formats/Heic/MetadataExtensions.cs b/src/ImageSharp/Formats/Heif/MetadataExtensions.cs similarity index 58% rename from src/ImageSharp/Formats/Heic/MetadataExtensions.cs rename to src/ImageSharp/Formats/Heif/MetadataExtensions.cs index b708bfc308..5962df213f 100644 --- a/src/ImageSharp/Formats/Heic/MetadataExtensions.cs +++ b/src/ImageSharp/Formats/Heif/MetadataExtensions.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using SixLabors.ImageSharp.Formats.Heic; +using SixLabors.ImageSharp.Formats.Heif; using SixLabors.ImageSharp.Metadata; namespace SixLabors.ImageSharp; @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp; public static partial class MetadataExtensions { /// - /// Gets the pbm format specific metadata for the image. + /// Gets the HEIF format specific metadata for the image. /// /// The metadata this method extends. - /// The . - public static HeicMetadata GetHeicMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(HeicFormat.Instance); + /// The . + public static HeifMetadata GetHeifMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(HeifFormat.Instance); } diff --git a/src/ImageSharp/Formats/Heic/Readme.md b/src/ImageSharp/Formats/Heif/Readme.md similarity index 100% rename from src/ImageSharp/Formats/Heic/Readme.md rename to src/ImageSharp/Formats/Heif/Readme.md diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 06e7d13336..63bc8131bd 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -52,10 +52,10 @@ - + True True - Heic4CharCode.tt + Heif4CharCode.tt True @@ -155,9 +155,9 @@ - + TextTemplatingFileGenerator - Heic4CharCode.cs + Heif4CharCode.cs TextTemplatingFileGenerator diff --git a/tests/ImageSharp.Tests/Formats/Heic/HeicDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Heif/HeifDecoderTests.cs similarity index 51% rename from tests/ImageSharp.Tests/Formats/Heic/HeicDecoderTests.cs rename to tests/ImageSharp.Tests/Formats/Heif/HeifDecoderTests.cs index e08d5b2208..78ada561c5 100644 --- a/tests/ImageSharp.Tests/Formats/Heic/HeicDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Heif/HeifDecoderTests.cs @@ -1,43 +1,43 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using SixLabors.ImageSharp.Formats.Heic; +using SixLabors.ImageSharp.Formats.Heif; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Tests.Formats.Heic; +namespace SixLabors.ImageSharp.Tests.Formats.Heif; -[Trait("Format", "Heic")] +[Trait("Format", "Heif")] [ValidateDisposedMemoryAllocations] -public class HeicDecoderTests +public class HeifDecoderTests { [Theory] - [InlineData(TestImages.Heic.Image1, HeicCompressionMethod.Hevc)] - [InlineData(TestImages.Heic.Sample640x427, HeicCompressionMethod.Hevc)] - [InlineData(TestImages.Heic.FujiFilmHif, HeicCompressionMethod.LegacyJpeg)] - [InlineData(TestImages.Heic.IrvineAvif, HeicCompressionMethod.Av1)] - public void Identify(string imagePath, HeicCompressionMethod compressionMethod) + [InlineData(TestImages.Heif.Image1, HeifCompressionMethod.Hevc)] + [InlineData(TestImages.Heif.Sample640x427, HeifCompressionMethod.Hevc)] + [InlineData(TestImages.Heif.FujiFilmHif, HeifCompressionMethod.LegacyJpeg)] + [InlineData(TestImages.Heif.IrvineAvif, HeifCompressionMethod.Av1)] + public void Identify(string imagePath, HeifCompressionMethod compressionMethod) { TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); ImageInfo imageInfo = Image.Identify(stream); - HeicMetadata heicMetadata = imageInfo.Metadata.GetHeicMetadata(); + HeifMetadata heicMetadata = imageInfo.Metadata.GetHeifMetadata(); Assert.NotNull(imageInfo); - Assert.Equal(HeicFormat.Instance, imageInfo.Metadata.DecodedImageFormat); + Assert.Equal(HeifFormat.Instance, imageInfo.Metadata.DecodedImageFormat); Assert.Equal(compressionMethod, heicMetadata.CompressionMethod); } [Theory] - [WithFile(TestImages.Heic.FujiFilmHif, PixelTypes.Rgba32)] + [WithFile(TestImages.Heif.FujiFilmHif, PixelTypes.Rgba32)] public void Decode(TestImageProvider provider) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - HeicMetadata heicMetadata = image.Metadata.GetHeicMetadata(); + HeifMetadata heicMetadata = image.Metadata.GetHeifMetadata(); image.DebugSave(provider); image.CompareToReferenceOutput(provider); - Assert.Equal(HeicCompressionMethod.Hevc, heicMetadata.CompressionMethod); + Assert.Equal(HeifCompressionMethod.LegacyJpeg, heicMetadata.CompressionMethod); } } diff --git a/tests/ImageSharp.Tests/Formats/Heic/HeicEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Heif/HeifEncoderTests.cs similarity index 60% rename from tests/ImageSharp.Tests/Formats/Heic/HeicEncoderTests.cs rename to tests/ImageSharp.Tests/Formats/Heif/HeifEncoderTests.cs index 3b6087d0a5..c7e0e8832d 100644 --- a/tests/ImageSharp.Tests/Formats/Heic/HeicEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Heif/HeifEncoderTests.cs @@ -1,32 +1,32 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using SixLabors.ImageSharp.Formats.Heic; +using SixLabors.ImageSharp.Formats.Heif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -namespace SixLabors.ImageSharp.Tests.Formats.Heic; +namespace SixLabors.ImageSharp.Tests.Formats.Heif; -[Trait("Format", "Heic")] +[Trait("Format", "Heif")] [ValidateDisposedMemoryAllocations] -public class HeicEncoderTests +public class HeifEncoderTests { [Theory] - [WithFile(TestImages.Heic.Sample640x427, PixelTypes.Rgba32)] - public static void Encode(TestImageProvider provider) + [WithFile(TestImages.Heif.Sample640x427, PixelTypes.Rgba32, HeifCompressionMethod.LegacyJpeg)] + public static void Encode(TestImageProvider provider, HeifCompressionMethod compressionMethod) where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(new MagickReferenceDecoder()); using MemoryStream stream = new(); - HeicEncoder encoder = new(); + HeifEncoder encoder = new(); image.Save(stream, encoder); stream.Position = 0; using Image encodedImage = Image.Load(stream); - HeicMetadata heicMetadata = encodedImage.Metadata.GetHeicMetadata(); + HeifMetadata heifMetadata = encodedImage.Metadata.GetHeifMetadata(); ImageComparer.Exact.CompareImages(image, encodedImage); - //Assert.Equal(heicMetadata.Channels, channels); + Assert.Equal(compressionMethod, heifMetadata.CompressionMethod); } } diff --git a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index 7d21de6dee..c7cdc4d3a6 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -5,8 +5,8 @@ using Moq; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; +using SixLabors.ImageSharp.Formats.Heif; using SixLabors.ImageSharp.Formats.Jpeg; -using SixLabors.ImageSharp.Formats.Heic; using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Tga; @@ -36,7 +36,7 @@ public class ImageFormatManagerTests Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); - Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); + Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); @@ -46,7 +46,7 @@ public class ImageFormatManagerTests Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); - Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); + Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 4b6b1463c0..8f2192af48 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1105,18 +1105,18 @@ public static class TestImages public const string Wikipedia008 = "Qoi/wikipedia_008.qoi"; } - public static class Heic + public static class Heif { - public const string Image1 = "Heic/image1.heic"; - public const string Image2 = "Heic/image2.heic"; - public const string Image3 = "Heic/image3.heic"; - public const string Image4 = "Heic/image4.heic"; - public const string Sample640x427 = "Heic/dwsample-heic-640.heic"; + public const string Image1 = "Heif/image1.heic"; + public const string Image2 = "Heif/image2.heic"; + public const string Image3 = "Heif/image3.heic"; + public const string Image4 = "Heif/image4.heic"; + public const string Sample640x427 = "Heif/dwsample-heic-640.heic"; // Downloaded from: https://github.com/draktable-org/darktable/issues/14473 - public const string FujiFilmHif = "Heic/IMG-20230508-0053.hif"; + public const string FujiFilmHif = "Heif/IMG-20230508-0053.hif"; // Downloaded from: https://github.com/AOMediaCodec/av1-avif/blob/master/testFiles/Microsoft/Irvine_CA.avif - public const string IrvineAvif = "Heic/Irvine_CA.avif"; + public const string IrvineAvif = "Heif/Irvine_CA.avif"; } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs index be3de2a4f8..7788296745 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs @@ -4,8 +4,8 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; +using SixLabors.ImageSharp.Formats.Heif; using SixLabors.ImageSharp.Formats.Jpeg; -using SixLabors.ImageSharp.Formats.Heic; using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Qoi; @@ -60,7 +60,7 @@ public static partial class TestEnvironment Configuration cfg = new( new JpegConfigurationModule(), new GifConfigurationModule(), - new HeicConfigurationModule(), + new HeifConfigurationModule(), new PbmConfigurationModule(), new TgaConfigurationModule(), new WebpConfigurationModule(), diff --git a/tests/Images/External/ReferenceOutput/HeicDecoderTests/Decode_Rgba32_IMG-20230508-0053.png b/tests/Images/External/ReferenceOutput/HeifDecoderTests/Decode_Rgba32_IMG-20230508-0053.png similarity index 100% rename from tests/Images/External/ReferenceOutput/HeicDecoderTests/Decode_Rgba32_IMG-20230508-0053.png rename to tests/Images/External/ReferenceOutput/HeifDecoderTests/Decode_Rgba32_IMG-20230508-0053.png