Merge remote-tracking branch 'origin/v13/dev' into v14/dev

This commit is contained in:
Bjarke Berg
2023-09-22 10:24:40 +02:00
3 changed files with 12 additions and 18 deletions

View File

@@ -64,7 +64,7 @@ public class CropWebProcessor : IImageWebProcessor
Vector2 xy2 = ExifOrientationUtilities.Transform(new Vector2(right, bottom), Vector2.Zero, Vector2.One, orientation);
// Scale points to a pixel based rectangle
Size size = image.Image.Size;
Size size = image.Image.Size();
return Rectangle.Round(RectangleF.FromLTRB(
MathF.Min(xy1.X, xy2.X) * size.Width,

View File

@@ -1,5 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using Umbraco.Cms.Core.Media;
using Size = System.Drawing.Size;
@@ -8,7 +7,7 @@ namespace Umbraco.Cms.Imaging.ImageSharp.Media;
public sealed class ImageSharpDimensionExtractor : IImageDimensionExtractor
{
private readonly DecoderOptions _decoderOptions;
private readonly Configuration _configuration;
/// <inheritdoc />
public IEnumerable<string> SupportedImageFileTypes { get; }
@@ -16,12 +15,12 @@ public sealed class ImageSharpDimensionExtractor : IImageDimensionExtractor
/// <summary>
/// Initializes a new instance of the <see cref="ImageSharpDimensionExtractor" /> class.
/// </summary>
/// <param name="decoderOptions">The configuration.</param>
public ImageSharpDimensionExtractor(DecoderOptions decoderOptions)
/// <param name="configuration">The configuration.</param>
public ImageSharpDimensionExtractor(Configuration configuration)
{
_decoderOptions = decoderOptions ?? throw new ArgumentNullException(nameof(decoderOptions));
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
SupportedImageFileTypes = decoderOptions.Configuration.ImageFormats.SelectMany(f => f.FileExtensions).ToArray();
SupportedImageFileTypes = configuration.ImageFormats.SelectMany(f => f.FileExtensions).ToArray();
}
/// <inheritdoc />
@@ -29,12 +28,7 @@ public sealed class ImageSharpDimensionExtractor : IImageDimensionExtractor
{
Size? size = null;
if (stream == null)
{
return size;
}
ImageInfo imageInfo = Image.Identify(_decoderOptions, stream);
IImageInfo imageInfo = Image.Identify(_configuration, stream);
if (imageInfo != null)
{
size = IsExifOrientationRotated(imageInfo)
@@ -45,7 +39,7 @@ public sealed class ImageSharpDimensionExtractor : IImageDimensionExtractor
return size;
}
private static bool IsExifOrientationRotated(ImageInfo imageInfo)
private static bool IsExifOrientationRotated(IImageInfo imageInfo)
=> GetExifOrientation(imageInfo) switch
{
ExifOrientationMode.LeftTop
@@ -55,10 +49,10 @@ public sealed class ImageSharpDimensionExtractor : IImageDimensionExtractor
_ => false,
};
private static ushort GetExifOrientation(ImageInfo imageInfo)
private static ushort GetExifOrientation(IImageInfo imageInfo)
{
if(imageInfo.Metadata.ExifProfile != null && imageInfo.Metadata.ExifProfile.TryGetValue(ExifTag.Orientation, out IExifValue<ushort>? orientation))
IExifValue<ushort>? orientation = imageInfo.Metadata.ExifProfile?.GetValue(ExifTag.Orientation);
if (orientation is not null)
{
if (orientation.DataType == ExifDataType.Short)
{

View File

@@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="2.0.2" />
</ItemGroup>