Skip to content
Open
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
8 changes: 6 additions & 2 deletions Source/Components/ImageGlass.Base/ImageInfo/ImageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static class ImageInfo

public static string? DateTimeAuto { get; set; } = null;
public static string? ColorSpace { get; set; } = null;
public static string? DPI { get; set; } = null;


public static bool IsNull => AppName == null
Expand All @@ -56,7 +57,9 @@ public static class ImageInfo
&& ExifDateTimeOriginal == null

&& ExifRating == null
&& ColorSpace == null;
&& ColorSpace == null

&& DPI == null;


/// <summary>
Expand All @@ -80,7 +83,8 @@ public static string ToString(List<string> infoTags, bool isVirtualImage, string
ExifDateTime =
ExifDateTimeOriginal =
DateTimeAuto =
ColorSpace = null;
ColorSpace =
DPI = null;

if (!string.IsNullOrEmpty(clipboardImageText))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ public enum ImageInfoUpdateTypes

ExifRating = 1 << 13,
ColorSpace = 1 << 14,

DPI = 1 << 15
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public class IgMetadata
public uint RenderedWidth { get; set; } = 0;
public uint RenderedHeight { get; set; } = 0;

// DPI
public float DpiX { get; set; } = 0;
public float DpiY { get; set; } = 0;

/// <summary>
/// Gets the frame index of this metadata.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public static class PhotoCodec
meta.RenderedHeight = imgM.Height;
}

// DPI
var density = imgM.Density;
// Convert units to inch
meta.DpiX = (float)density.X * 2.54f;
meta.DpiY = (float)density.Y * 2.54f;

// image color
meta.HasAlpha = imgC.Any(i => i.HasAlpha);
Expand Down
16 changes: 15 additions & 1 deletion Source/ImageGlass/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,9 +1567,23 @@ public void LoadImageInfo(ImageInfoUpdateTypes? types = null, string? filename =
}
}

// DPI
if (updateAll || types!.Value.HasFlag(ImageInfoUpdateTypes.DPI))
{
if (Config.ImageInfoTags.Contains(nameof(ImageInfo.DPI))
&& Local.Metadata != null
&& Local.Metadata.DpiX > 0
&& Local.Metadata.DpiY > 0)
{
ImageInfo.DPI = $"{Local.Metadata.DpiX:n0}×{Local.Metadata.DpiY:n0} DPI";
}
else
{
ImageInfo.DPI = string.Empty;
}
}
}


Text = ImageInfo.ToString(Config.ImageInfoTags, Local.ClipboardImage != null, clipboardImageText);
}

Expand Down
16 changes: 15 additions & 1 deletion Source/igcmd/Tools/FrmSlideshow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,21 @@ private void LoadImageInfo(ImageInfoUpdateTypes? types = null, string? filePath
}
}


// DPI
if (updateAll || types!.Value.HasFlag(ImageInfoUpdateTypes.DPI))
{
if (Config.ImageInfoTags.Contains(nameof(ImageInfo.DPI))
&& _currentMetadata != null
&& _currentMetadata.DpiX > 0
&& _currentMetadata.DpiY > 0)
{
ImageInfo.DPI = $"{_currentMetadata.DpiX:n0}×{_currentMetadata.DpiY:n0} DPI";
}
else
{
ImageInfo.DPI = string.Empty;
}
}

Text = ImageInfo.ToString(Config.ImageInfoTags, false);
}
Expand Down