diff --git a/backend/src/Squidex.Infrastructure/Assets/ImageSharp/ImageSharpAssetThumbnailGenerator.cs b/backend/src/Squidex.Infrastructure/Assets/ImageSharp/ImageSharpAssetThumbnailGenerator.cs
index 7b900a840..5e12251a8 100644
--- a/backend/src/Squidex.Infrastructure/Assets/ImageSharp/ImageSharpAssetThumbnailGenerator.cs
+++ b/backend/src/Squidex.Infrastructure/Assets/ImageSharp/ImageSharpAssetThumbnailGenerator.cs
@@ -11,7 +11,6 @@ using System.Threading.Tasks;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Processing;
-using SixLabors.Primitives;
using ISResizeMode = SixLabors.ImageSharp.Processing.ResizeMode;
using ISResizeOptions = SixLabors.ImageSharp.Processing.ResizeOptions;
@@ -39,7 +38,7 @@ namespace Squidex.Infrastructure.Assets.ImageSharp
{
var encoder = Configuration.Default.ImageFormatsManager.FindEncoder(format);
- if (options.Quality.HasValue)
+ if (options.Quality.HasValue && (encoder is JpegEncoder || !options.KeepFormat))
{
encoder = new JpegEncoder { Quality = options.Quality.Value };
}
@@ -72,11 +71,10 @@ namespace Squidex.Infrastructure.Assets.ImageSharp
if (options.FocusX.HasValue && options.FocusY.HasValue)
{
- resizeOptions.CenterCoordinates = new float[]
- {
+ resizeOptions.CenterCoordinates = new PointF(
+(options.FocusX.Value / 2f) + 0.5f,
- -(options.FocusX.Value / 2f) + 0.5f
- };
+ -(options.FocusY.Value / 2f) + 0.5f
+ );
}
sourceImage.Mutate(x => x.Resize(resizeOptions));
diff --git a/backend/src/Squidex.Infrastructure/Assets/ResizeOptions.cs b/backend/src/Squidex.Infrastructure/Assets/ResizeOptions.cs
index b866003ec..de5da4393 100644
--- a/backend/src/Squidex.Infrastructure/Assets/ResizeOptions.cs
+++ b/backend/src/Squidex.Infrastructure/Assets/ResizeOptions.cs
@@ -23,6 +23,8 @@ namespace Squidex.Infrastructure.Assets
public float? FocusY { get; set; }
+ public bool KeepFormat { get; set; }
+
public bool IsValid
{
get { return Width > 0 || Height > 0 || Quality > 0; }
diff --git a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
index 35a4bda8f..6cd1437b6 100644
--- a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
+++ b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
@@ -31,7 +31,7 @@
-
+
diff --git a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs
index 91147ae6d..91257506b 100644
--- a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs
+++ b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs
@@ -75,6 +75,12 @@ namespace Squidex.Areas.Api.Controllers.Assets.Models
[FromQuery(Name = "nofocus")]
public bool IgnoreFocus { get; set; }
+ ///
+ /// True to not use JPEG encoding when quality is set and the image is not a JPEG. Default: false.
+ ///
+ [FromQuery(Name = "keepformat")]
+ public bool KeepFormat { get; set; }
+
///
/// True to force a new resize even if it already stored.
///