diff --git a/src/ImageSharp/Formats/Gif/GifConstants.cs b/src/ImageSharp/Formats/Gif/GifConstants.cs
index c9d631da0..c945ce122 100644
--- a/src/ImageSharp/Formats/Gif/GifConstants.cs
+++ b/src/ImageSharp/Formats/Gif/GifConstants.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Collections.Generic;
using System.Text;
@@ -21,11 +22,6 @@ namespace SixLabors.ImageSharp.Formats.Gif
///
public const string FileVersion = "89a";
- ///
- /// The ASCII encoded bytes used to identify the GIF file.
- ///
- internal static readonly byte[] MagicNumber = Encoding.ASCII.GetBytes(FileType + FileVersion);
-
///
/// The extension block introducer !.
///
@@ -51,11 +47,6 @@ namespace SixLabors.ImageSharp.Formats.Gif
///
public const string NetscapeApplicationIdentification = "NETSCAPE2.0";
- ///
- /// The ASCII encoded application identification bytes.
- ///
- internal static readonly byte[] NetscapeApplicationIdentificationBytes = Encoding.ASCII.GetBytes(NetscapeApplicationIdentification);
-
///
/// The Netscape looping application sub block size.
///
@@ -101,6 +92,26 @@ namespace SixLabors.ImageSharp.Formats.Gif
///
public static readonly Encoding Encoding = Encoding.ASCII;
+ ///
+ /// Gets the ASCII encoded bytes used to identify the GIF file (combining and ).
+ ///
+ internal static ReadOnlySpan MagicNumber => new[]
+ {
+ (byte)'G', (byte)'I', (byte)'F',
+ (byte)'8', (byte)'9', (byte)'a'
+ };
+
+ ///
+ /// Gets the ASCII encoded application identification bytes (representing ).
+ ///
+ internal static ReadOnlySpan NetscapeApplicationIdentificationBytes => new[]
+ {
+ (byte)'N', (byte)'E', (byte)'T',
+ (byte)'S', (byte)'C', (byte)'A',
+ (byte)'P', (byte)'E',
+ (byte)'2', (byte)'.', (byte)'0'
+ };
+
///
/// The collection of mimetypes that equate to a Gif.
///
diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
index 3a0fa5169..e9506714f 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
@@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
///
/// The stream to write to.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void WriteHeader(Stream stream) => stream.Write(GifConstants.MagicNumber, 0, GifConstants.MagicNumber.Length);
+ private void WriteHeader(Stream stream) => stream.Write(GifConstants.MagicNumber);
///
/// Writes the logical screen descriptor to the stream.
diff --git a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
index 8af5b81c2..5e26370ba 100644
--- a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
+++ b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs
@@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
buffer[0] = GifConstants.ApplicationBlockSize;
// Write NETSCAPE2.0
- GifConstants.NetscapeApplicationIdentificationBytes.AsSpan().CopyTo(buffer.Slice(1, 11));
+ GifConstants.NetscapeApplicationIdentificationBytes.CopyTo(buffer.Slice(1, 11));
// Application Data ----
buffer[12] = 3; // Application block length (always 3)