Skip to content

Commit

Permalink
Exif XPSubject conversion #145
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 19, 2024
1 parent 53f7047 commit d9043b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PicView.Avalonia/Navigation/ExifHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static void UpdateExifValues(ImageModel imageModel, MainViewModel vm)
vm.GetDateTaken = EXIFHelper.GetDateTaken(profile);
vm.GetCopyright = profile?.GetValue(ExifTag.Copyright)?.Value ?? string.Empty;
vm.GetTitle = EXIFHelper.GetTitle(profile);
vm.GetSubject = profile?.GetValue(ExifTag.XPSubject)?.Value.ToString() ?? string.Empty;
vm.GetSubject = EXIFHelper.GetSubject(profile);
vm.GetSoftware = profile?.GetValue(ExifTag.Software)?.Value ?? string.Empty;
vm.GetResolutionUnit = EXIFHelper.GetResolutionUnit(profile);
vm.GetColorRepresentation = EXIFHelper.GetColorSpace(profile);
Expand Down
12 changes: 12 additions & 0 deletions src/PicView.Core/ImageDecoding/EXIFHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,16 @@ public static string GetExifVersion(IExifProfile? profile)
var titleTag = profile?.GetValue(ExifTag.ImageDescription)?.Value;
return titleTag ?? string.Empty;
}

public static string? GetSubject(IExifProfile? profile)
{
var xPSubject = profile?.GetValue(ExifTag.XPSubject)?.Value;
var subject = xPSubject is null ? string.Empty : Encoding.ASCII.GetString(xPSubject);
if (!string.IsNullOrEmpty(subject))
{
return subject;
}
var subjectTag = profile?.GetValue(ExifTag.XPSubject)?.Value;
return subjectTag?.GetValue(0)?.ToString() ?? string.Empty;
}
}

0 comments on commit d9043b0

Please sign in to comment.