Skip to content

Commit

Permalink
Meta for images
Browse files Browse the repository at this point in the history
  • Loading branch information
fgilde committed Sep 2, 2024
1 parent cb20843 commit 4002d0e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions MudBlazor.Extensions/Components/MudExAudioPlayer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ private void ApplyInitialSettingsForFileView(bool withPreset)

KeepState = true;
ApplyBackgroundImageFromTrack = false;
PreviewImageInPresetList = true;
InitialRender = InitialRender.WithRandomData;

Height = Width = "100%";
Expand Down
17 changes: 16 additions & 1 deletion MudBlazor.Extensions/Components/MudExImageViewer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using MudBlazor.Interop;
using MetadataExtractor;

namespace MudBlazor.Extensions.Components;

Expand Down Expand Up @@ -554,7 +555,21 @@ public async Task SaveImageAsync(MudExImageViewerSaveOptions options)
});
}

public Task<IDictionary<string, object>> FileMetaInformationAsync(IMudExFileDisplayInfos fileDisplayInfos) => Task.FromResult<IDictionary<string, object>>(null);
public async Task<IDictionary<string, object>> FileMetaInformationAsync(IMudExFileDisplayInfos fileDisplayInfos)
{
var stream = fileDisplayInfos?.ContentStream ?? await Get<MudExFileService>().ReadStreamAsync(Src);
var meta = ImageMetadataReader.ReadMetadata(stream);
var result = new Dictionary<string, object>();
foreach (var directory in meta)
{
foreach (var tag in directory.Tags)
{
result.Add($"{directory.Name} - {tag.Name}", tag.Description);
}
}

return result;
}

private Task<string> ConvertImageToAsync(Stream stream, ImageViewerExportFormat format = ImageViewerExportFormat.Png) => ConvertImageToAsync(stream, MudExImageViewerSaveOptions.GetImageFormat(format));

Expand Down
1 change: 1 addition & 0 deletions MudBlazor.Extensions/MudBlazor.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<PackageReference Include="BlazorParameterCastingMagic" Version="1.2.23060811" />
<PackageReference Include="SharpCompress" Version="0.37.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 4002d0e

Please sign in to comment.