Skip to content

Commit

Permalink
meta.ColorProfile: show profile description
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed May 11, 2024
1 parent e8f34a6 commit c7ad52c
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions Source/Components/ImageGlass.Base/Photoing/Codecs/PhotoCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,34 @@ public static class PhotoCodec
meta.FrameIndex = (uint)frameIndex;
using var imgM = imgC[frameIndex];


// image size
meta.OriginalWidth = imgM.BaseWidth;
meta.OriginalHeight = imgM.BaseHeight;

if (options?.AutoScaleDownLargeImage == true)
{
var newSize = GetMaxImageRenderSize(imgM.BaseWidth, imgM.BaseHeight);

meta.RenderedWidth = newSize.Width;
meta.RenderedHeight = newSize.Height;
}
else
{
meta.RenderedWidth = imgM.Width;
meta.RenderedHeight = imgM.Height;
}


// image color
meta.HasAlpha = imgC.Any(i => i.HasAlpha);
meta.ColorSpace = imgM.ColorSpace.ToString();

var isAnimatedExtension = ext == ".GIF" || ext == ".GIFV" || ext == ".WEBP";
meta.CanAnimate = imgC.Count > 1
&& (isAnimatedExtension || imgC.Any(i => i.GifDisposeMethod != GifDisposeMethod.Undefined));


// EXIF profile
if (imgM.GetExifProfile() is IExifProfile exifProfile)
{
Expand Down Expand Up @@ -142,7 +170,7 @@ public static class PhotoCodec
using var img = Image.FromStream(fs, false, false);
var enc = new ASCIIEncoding();

var EXIF_DateTimeOriginal = 0x9003; //36867;
var EXIF_DateTimeOriginal = 0x9003; //36867
var EXIF_DateTime = 0x0132;

try
Expand Down Expand Up @@ -175,34 +203,17 @@ public static class PhotoCodec
catch { }
}


// Color profile
if (imgM.GetColorProfile() is IColorProfile colorProfile)
{
meta.ColorProfile = colorProfile.ColorSpace.ToString();
}

if (options?.AutoScaleDownLargeImage == true)
{
var newSize = GetMaxImageRenderSize(imgM.BaseWidth, imgM.BaseHeight);

meta.RenderedWidth = newSize.Width;
meta.RenderedHeight = newSize.Height;
}
else
{
meta.RenderedWidth = imgM.Width;
meta.RenderedHeight = imgM.Height;
if (!string.IsNullOrWhiteSpace(colorProfile.Description))
{
meta.ColorProfile = $"{colorProfile.Description} ({meta.ColorProfile})";
}
}

meta.OriginalWidth = imgM.BaseWidth;
meta.OriginalHeight = imgM.BaseHeight;

meta.HasAlpha = imgC.Any(i => i.HasAlpha);
meta.ColorSpace = imgM.ColorSpace.ToString();

var isAnimatedExtension = ext == ".GIF" || ext == ".GIFV" || ext == ".WEBP";
meta.CanAnimate = imgC.Count > 1
&& (isAnimatedExtension || imgC.Any(i => i.GifDisposeMethod != GifDisposeMethod.Undefined));
}
}
catch { }
Expand Down

0 comments on commit c7ad52c

Please sign in to comment.