Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert debian base image change #345

Merged
merged 19 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Accord/Accord.Imaging/Accord.Imaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<None Remove="System.Drawing.Common" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="6.0.2-mauipre.1.22054.8" />
<PackageReference Include="System.Drawing.Common" Version="6.0.2-mauipre.1.22102.15" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Core.DbModels/Damselfly.Core.DbModels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.2-mauipre.1.22054.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.2" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Core.ImageProcessing/ImageMagickProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA
Logging.LogVerbose(e.Data);
}

public void TransformDownloadImage(string input, Stream output, IExportSettings config)
public Task TransformDownloadImage(string input, Stream output, IExportSettings config)
{
throw new NotImplementedException();
}
Expand Down
4 changes: 2 additions & 2 deletions Damselfly.Core.ImageProcessing/ImageSharpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public async Task GetCroppedFile( FileInfo source, int x, int y, int width, int
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="waterMarkText"></param>
public void TransformDownloadImage(string input, Stream output, IExportSettings config)
public async Task TransformDownloadImage(string input, Stream output, IExportSettings config)
{
Logging.Log($" Running image transform for Watermark: {config.WatermarkText}");

Expand Down Expand Up @@ -257,7 +257,7 @@ public void TransformDownloadImage(string input, Stream output, IExportSettings
img.Mutate(context => ApplyWaterMark(context, font, config.WatermarkText, Color.White));
}

img.Save(output, fmt);
await img.SaveAsync(output, fmt);
}


Expand Down
14 changes: 13 additions & 1 deletion Damselfly.Core.ImageProcessing/SkiaSharpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,25 @@ private static SKBitmap AutoOrient(SKBitmap original, SKEncodedOrigin origin)
return rotated;
}

/// <summary>
/// Async wrapper - note that Skia Sharp doesn't support Async yet.
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="config"></param>
/// <returns></returns>
public async Task TransformDownloadImage(string input, Stream output, IExportSettings config)
{
await Task.Run(() => TransformDownloadImageSync(input, output, config));
}

/// <summary>
/// Transform the images ready for download, optionally adding a watermark.
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="waterMarkText"></param>
public void TransformDownloadImage(string input, Stream output, IExportSettings config)
public void TransformDownloadImageSync(string input, Stream output, IExportSettings config)
{
using SKImage img = SKImage.FromEncodedData(input);
using var bitmap = SKBitmap.FromImage(img);
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Core.Interfaces/IImageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface IImageProcessor
{
Task<ImageProcessResult> CreateThumbs(FileInfo source, IDictionary<FileInfo, ThumbConfig> destFiles );
Task GetCroppedFile(FileInfo source, int x, int y, int width, int height, FileInfo destFile);
void TransformDownloadImage(string input, Stream output, IExportSettings exportConfig);
Task TransformDownloadImage(string input, Stream output, IExportSettings exportConfig);

static ICollection<string> SupportedFileExtensions { get; }
}
Expand Down
2 changes: 2 additions & 0 deletions Damselfly.Core.Utils/Constants/ConfigSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class ConfigSettings
public const string ShowZoom = "ShowZoom";
public const string ShowObjects = "ShowObjects";
public const string SelectedBasketId = "SelectedBasketId";
public const string SideBarWidth = "SideBarWidth";
public const string SideBarCollapsed = "SideBarCollapsed";

public const string WordpressURL = "WordpressURL";
public const string WordpressUser = "WordpressUser";
Expand Down
1 change: 1 addition & 0 deletions Damselfly.Core.Utils/Constants/ExportTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum ExportSize
Large = 2,
Medium = 3,
Small = 4,
ExtraLarge = 5
};
}

2 changes: 1 addition & 1 deletion Damselfly.Core.Utils/Damselfly.Core.Utils.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Serilog" Version="2.11.0-dev-01377" />
<PackageReference Include="Serilog" Version="2.11.0-dev-01380" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00947" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.2-dev-00890" />
<PackageReference Include="Humanizer" Version="2.14.1" />
Expand Down
10 changes: 5 additions & 5 deletions Damselfly.Core/Damselfly.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="font-awesome" Version="4.7.0" />
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.155" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.155" />
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.187" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.187" />
<PackageReference Include="FluentValidation" Version="10.3.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.2-mauipre.1.22054.8" />
<PackageReference Include="System.Drawing.Common" Version="6.0.2-mauipre.1.22054.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="System.Drawing.Common" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.2" />
<PackageReference Include="SendGrid" Version="9.25.3" />
<PackageReference Include="MailKit" Version="3.1.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="CoenM.ImageSharp.ImageHash" Version="1.1.5" />
<PackageReference Include="CoenM.ImageSharp.ImageHash" Version="1.2.30" />
<PackageReference Include="MudBlazor" Version="6.0.6" />
</ItemGroup>
<ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions Damselfly.Core/Models/ImageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,19 +676,19 @@ public class ExportConfig : IExportSettings
public bool KeepFolders { get; set; }
public string WatermarkText { get; set; }

public int MaxImageSize
{
get
public int MaxImageSize => MaxSize(Size);
public string SizeDesc() => SizeDesc(Size);

public static string SizeDesc(ExportSize size) => $"{size.Humanize()}" + (size == ExportSize.FullRes ? "" : $" (max {MaxSize(size)}x{MaxSize(size)})");
public static int MaxSize( ExportSize size ) =>
size switch
{
return Size switch
{
ExportSize.Large => 1600,
ExportSize.Medium => 1024,
ExportSize.Small => 800,
_ => int.MaxValue,
};
}
}
ExportSize.ExtraLarge => 1920,
ExportSize.Large => 1600,
ExportSize.Medium => 1024,
ExportSize.Small => 800,
_ => int.MaxValue,
};
}

/// <summary>
Expand Down
11 changes: 8 additions & 3 deletions Damselfly.Core/ScopedServices/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class SearchResponse
private readonly MetaDataService _metadataService;
private readonly SearchQuery query = new SearchQuery();
public List<Image> SearchResults { get; private set; } = new List<Image>();
private const double s_similarityThreshold = 0.75;

public void NotifyStateChanged()
{
Expand Down Expand Up @@ -97,8 +96,11 @@ public void SetDateRange( DateTime? min, DateTime? max )

private void QueryChanged()
{
SearchResults.Clear();
NotifyStateChanged();
Task.Run(() =>
{
SearchResults.Clear();
NotifyStateChanged();
});
}

/// <summary>
Expand Down Expand Up @@ -395,6 +397,9 @@ public string SearchBreadcrumbs
if (Person != null)
hints.Add($"Person: {Person.Name}");

if (MinRating != null)
hints.Add($"Rating: at least {MinRating} stars");

if (SimilarTo != null)
hints.Add($"Looks Like: {SimilarTo.FileName}");

Expand Down
3 changes: 1 addition & 2 deletions Damselfly.Core/Services/DownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ public async Task<string> CreateDownloadZipAsync(FileInfo[] filesToZip, ExportCo
{
// Run the transform - note we do this in-memory and directly on the stream so the
// transformed file is never actually written to disk other than in the zip.
await Task.Run(() => _imageProcessingService.TransformDownloadImage(imagePath.FullName,
zipStream, config));
await _imageProcessingService.TransformDownloadImage(imagePath.FullName, zipStream, config);
}
}
}
Expand Down
93 changes: 43 additions & 50 deletions Damselfly.Core/Services/ExifService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ public async Task UpdateTagsAsync(Image image, List<string> addTags, List<string
/// <returns></returns>
public async Task UpdateFaceDataAsync(Image[] images, List<ImageObject> faces, AppIdentityUser user = null)
{
// TODO: Split tags with commas here?
#if ! DEBUG
// Not supported yet....
return;
# endif

var timestamp = DateTime.UtcNow;
var changeDesc = string.Empty;

Expand Down Expand Up @@ -292,8 +296,7 @@ private async Task<bool> ProcessExifOperations(int imageId, List<ExifOperation>

Logging.LogVerbose("Updating tags for file {0}", image.FullPath);
string args = string.Empty;
List<ExifOperation> processedOps = new List<ExifOperation>();
bool needExecuteExifTool = false;
List<ExifOperation> opsToProcess = new List<ExifOperation>();

foreach (var op in exifOperations)
{
Expand Down Expand Up @@ -321,78 +324,70 @@ private async Task<bool> ProcessExifOperations(int imageId, List<ExifOperation>
if (op.Operation == ExifOperation.OperationType.Remove)
{
Logging.LogVerbose($" Removing keyword {operationText} from {op.Image.FileName}");
processedOps.Add(op);
opsToProcess.Add(op);
}
else if (op.Operation == ExifOperation.OperationType.Add)
{
Logging.LogVerbose($" Adding keyword '{operationText}' to {op.Image.FileName}");
args += $" -keywords+=\"{operationText}\" ";
processedOps.Add(op);
opsToProcess.Add(op);
}

needExecuteExifTool = true;
}
else if( op.Type == ExifOperation.ExifType.Caption )
{
args += $" -iptc:Caption-Abstract=\"{op.Text}\"";
processedOps.Add(op);
needExecuteExifTool = true;
opsToProcess.Add(op);
}
else if (op.Type == ExifOperation.ExifType.Description)
{
args += $" -Exif:ImageDescription=\"{op.Text}\"";
processedOps.Add(op);
needExecuteExifTool = true;
opsToProcess.Add(op);
}
else if (op.Type == ExifOperation.ExifType.Copyright)
{
args += $" -Copyright=\"{op.Text}\"";
args += $" -iptc:CopyrightNotice=\"{op.Text}\"";
processedOps.Add(op);
needExecuteExifTool = true;
opsToProcess.Add(op);
}
else if (op.Type == ExifOperation.ExifType.Rating)
{
args += $" -exif:Rating=\"{op.Text}\"";
processedOps.Add(op);
needExecuteExifTool = true;
opsToProcess.Add(op);
}
else if (op.Type == ExifOperation.ExifType.Face)
{
#if DEBUG
var imageObject = JsonSerializer.Deserialize<ImageObject>(op.Text);

// Face tags using MGW standard
// exiftool -xmp-mwg-rs:RegionAppliedToDimensionsH=4000 -xmp-mwg-rs:RegionAppliedToDimensionsUnit="pixel" -xmp-mwg-rs:RegionAppliedToDimensionsW=6000
// -xmp-mwg-rs:RegionAreaX=0.319270833 -xmp-mwg-rs:RegionAreaY=0.21015625 -xmp-mwg-rs:RegionAreaW=0.165104167 -xmp-mwg-rs:RegionAreaH=0.30390625
// -xmp-mwg-rs:RegionName=John -xmp-mwg-rs:RegionRotation=0 -xmp-mwg-rs:RegionType="Face" myfile.xmp

// TODO: How to add multiple faces?
args += $" -xmp-mwg-rs:RegionType=\"Face\"";
args += $" -xmp-mwg-rs:RegionAppliedToDimensionsUnit=\"pixel\"";
args += $" -xmp-mwg-rs:RegionAppliedToDimensionsH=4000";
args += $" -xmp-mwg-rs:RegionAppliedToDimensionsW=6000";
args += $" -xmp-mwg-rs:RegionAreaX=0.319270833 -xmp-mwg-rs:RegionAreaY=0.21015625";
args += $" -xmp-mwg-rs:RegionAreaW=0.165104167 -xmp-mwg-rs:RegionAreaH=0.30390625";
args += $" -xmp-mwg-rs:RegionRotation=0";

if (imageObject.Person != null)
if (System.Diagnostics.Debugger.IsAttached)
{
args += $" -xmp-mwg-rs:RegionName={imageObject.Person.Name}";
}
// TODO: How to add multiple faces?
args += $" -xmp-mwg-rs:RegionType=\"Face\"";
args += $" -xmp-mwg-rs:RegionAppliedToDimensionsUnit=\"pixel\"";
args += $" -xmp-mwg-rs:RegionAppliedToDimensionsH=4000";
args += $" -xmp-mwg-rs:RegionAppliedToDimensionsW=6000";
args += $" -xmp-mwg-rs:RegionAreaX=0.319270833 -xmp-mwg-rs:RegionAreaY=0.21015625";
args += $" -xmp-mwg-rs:RegionAreaW=0.165104167 -xmp-mwg-rs:RegionAreaH=0.30390625";
args += $" -xmp-mwg-rs:RegionRotation=0";

if (imageObject.Person != null)
{
args += $" -xmp-mwg-rs:RegionName={imageObject.Person.Name}";
}

processedOps.Add(op);
needExecuteExifTool = true;
#else
op.State = ExifOperation.FileWriteState.Failed;
Logging.Log("Writing Face EXIF data is not supported at this time.");
#endif
opsToProcess.Add(op);
}
}
}

var db = new ImageContext();
// Assume they've all failed unless we succeed below.
exifOperations.ForEach(x => x.State = ExifOperation.FileWriteState.Failed);

if (needExecuteExifTool)
if (opsToProcess.Any() )
{
// Note: we could do this to preserve the last-mod-time:
// args += " -P -overwrite_original_in_place";
Expand All @@ -419,33 +414,31 @@ private async Task<bool> ProcessExifOperations(int imageId, List<ExifOperation>

if (success)
{
processedOps.ForEach(x => x.State = ExifOperation.FileWriteState.Written);
opsToProcess.ForEach(x => x.State = ExifOperation.FileWriteState.Written);

// Updating the timestamp on the image to newer than its metadata will
// trigger its metadata and tags to be refreshed during the next scan
await _indexingService.MarkImagesForScan(new[] { image });
}
else
{
processedOps.ForEach(x => x.State = ExifOperation.FileWriteState.Failed);
Logging.LogError("ExifTool Tag update failed for image: {0}", image.FullPath);

RestoreTempExifImage(image.FullPath);
}
}

using var db = new ImageContext();

// Now write the updates
await db.BulkUpdate(db.KeywordOperations, processedOps);
await db.BulkUpdate(db.KeywordOperations, exifOperations);

if( needExecuteExifTool )
{
var totals = string.Join(", ", exifOperations.GroupBy(x => x.State)
.Select(x => $"{x.Key}: {x.Count()}")
.ToList());
// Now write a summary of how many succeeded and failed.
var totals = string.Join(", ", exifOperations.GroupBy(x => x.State)
.Select(x => $"{x.Key}: {x.Count()}")
.ToList());

_statusService.StatusText = $"EXIF data written for {image.FileName}. {totals}";
}

_statusService.StatusText = $"EXIF data written for {image.FileName}. {totals}";

return success;
}

Expand Down Expand Up @@ -588,7 +581,7 @@ private async Task<IDictionary<int, List<ExifOperation>>> ConflateOperations(Lis

if (discardedOps.Any())
{
var db = new ImageContext();
using var db = new ImageContext();

// Mark the ops as discarded, and save them.
discardedOps.ForEach(x => x.State = ExifOperation.FileWriteState.Discarded);
Expand Down Expand Up @@ -690,7 +683,7 @@ public async Task Process()

public async Task<ICollection<IProcessJob>> GetPendingJobs(int maxCount)
{
var db = new ImageContext();
using var db = new ImageContext();

// We skip any operations where the timestamp is more recent than 30s
var timeThreshold = DateTime.UtcNow.AddSeconds(-1 * s_exifWriteDelay);
Expand Down
Loading