forked from Kieran/void.cat
Add rotation metadata
This commit is contained in:
parent
354d8312d6
commit
d243253af0
@ -59,7 +59,7 @@ namespace VoidCat.Model
|
||||
/// <summary>
|
||||
/// CORS origins
|
||||
/// </summary>
|
||||
public List<Uri> CorsOrigins { get; init; } = new();
|
||||
public List<string> CorsOrigins { get; init; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Cloud file storage settings
|
||||
|
@ -1,3 +1,4 @@
|
||||
using ExifLibrary;
|
||||
using FFMpegCore;
|
||||
|
||||
namespace VoidCat.Services.Files;
|
||||
@ -21,6 +22,7 @@ public class CompressContent
|
||||
{
|
||||
string? outMime = null;
|
||||
var inExt = Path.GetExtension(input).ToLower();
|
||||
var isImage = false;
|
||||
switch (inExt)
|
||||
{
|
||||
case ".jpg":
|
||||
@ -32,10 +34,12 @@ public class CompressContent
|
||||
{
|
||||
output = Path.ChangeExtension(output, ".webp");
|
||||
outMime = "image/webp";
|
||||
isImage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var probe = isImage ? await ImageFile.FromFileAsync(input) : default;
|
||||
var ffmpeg = FFMpegArguments
|
||||
.FromFileInput(input)
|
||||
.OutputToFile(output, true, o =>
|
||||
@ -45,6 +49,22 @@ public class CompressContent
|
||||
{
|
||||
o.Loop(0);
|
||||
}
|
||||
|
||||
if (probe != default)
|
||||
{
|
||||
var orientation = probe.Properties.Get<ExifEnumProperty<Orientation>>(ExifTag.Orientation);
|
||||
if (orientation != default && orientation.Value != Orientation.Normal)
|
||||
{
|
||||
if (orientation.Value == Orientation.RotatedRight)
|
||||
{
|
||||
o.WithCustomArgument("-metadata:s:v rotate=\"90\"");
|
||||
}
|
||||
else if (orientation.Value == Orientation.RotatedLeft)
|
||||
{
|
||||
o.WithCustomArgument("-metadata:s:v rotate=\"-90\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.CancellableThrough(cts);
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.103.41" />
|
||||
<PackageReference Include="BencodeNET" Version="5.0.0" />
|
||||
<PackageReference Include="BTCPayServer.Lightning.Common" Version="1.3.21" />
|
||||
<PackageReference Include="ExifLibNet" Version="2.1.4" />
|
||||
<PackageReference Include="FFMpegCore" Version="5.1.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.22.3" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.52.0" />
|
||||
|
@ -112,7 +112,7 @@ public static class VoidStartup
|
||||
|
||||
if (voidSettings.CorsOrigins.Count > 0)
|
||||
{
|
||||
p.WithOrigins(voidSettings.CorsOrigins.Select(a => a.ToString()).ToArray())
|
||||
p.WithOrigins(voidSettings.CorsOrigins.ToArray())
|
||||
.AllowCredentials();
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user