mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-04 03:36:04 +00:00
Show Exif info when previewing images
This commit is contained in:
@@ -8,8 +8,18 @@
|
||||
mc:Ignorable="d"
|
||||
x:Name="imagePanel"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.Dark.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Rectangle Visibility="{Binding BackgroundVisibility, ElementName=imagePanel}" RenderOptions.BitmapScalingMode="NearestNeighbor">
|
||||
<Rectangle Visibility="{Binding BackgroundVisibility, ElementName=imagePanel}"
|
||||
RenderOptions.BitmapScalingMode="NearestNeighbor">
|
||||
<Rectangle.Fill>
|
||||
<ImageBrush x:Name="backgroundBrush" ImageSource="Resources/background-b.png" AlignmentY="Top"
|
||||
Viewport="0,0,32,32"
|
||||
@@ -18,15 +28,19 @@
|
||||
</Rectangle>
|
||||
<ScrollViewer x:Name="viewPanel" BorderThickness="0" HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto" Focusable="False" IsManipulationEnabled="True">
|
||||
<animatedImage:AnimatedImage x:Name="viewPanelImage" Stretch="None" Meta="{Binding Meta, ElementName=imagePanel}"
|
||||
<animatedImage:AnimatedImage x:Name="viewPanelImage" Stretch="None"
|
||||
Meta="{Binding Meta, ElementName=imagePanel}"
|
||||
RenderOptions.BitmapScalingMode="{Binding RenderMode, ElementName=imagePanel}"
|
||||
AnimationUri="{Binding ImageUriSource, ElementName=imagePanel}" />
|
||||
</ScrollViewer>
|
||||
<Border x:Name="zoomLevelInfo" CornerRadius="5" IsHitTestVisible="False" Opacity="0" Background="Gray" Padding="15,4,15,4" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Foreground="White" FontSize="18" Text="{Binding ElementName=imagePanel, Path=ZoomFactor, StringFormat={}{0:P0}}" />
|
||||
<Border x:Name="zoomLevelInfo" CornerRadius="5" IsHitTestVisible="False" Opacity="0" Background="Gray"
|
||||
Padding="15,4,15,4" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Foreground="White" FontSize="18"
|
||||
Text="{Binding ElementName=imagePanel, Path=ZoomFactor, StringFormat={}{0:P0}}" />
|
||||
<Border.Resources>
|
||||
<Storyboard x:Key="StoryboardShowZoomLevelInfo">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.Target="{Binding Source={x:Reference zoomLevelInfo}}" Storyboard.TargetProperty="Opacity">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.Target="{Binding Source={x:Reference zoomLevelInfo}}"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DoubleAnimationUsingKeyFrames.KeyFrames>
|
||||
<LinearDoubleKeyFrame Value="0.9" KeyTime="0:0:0.1" />
|
||||
<LinearDoubleKeyFrame Value="0.9" KeyTime="0:0:0.6" />
|
||||
@@ -36,5 +50,18 @@
|
||||
</Storyboard>
|
||||
</Border.Resources>
|
||||
</Border>
|
||||
|
||||
<Button x:Name="buttonMeta" Style="{StaticResource CaptionButtonStyle}" Width="24" Height="24"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
Margin="0,8,8,0" Content="" />
|
||||
|
||||
<TextBlock x:Name="textMeta" IsHitTestVisible="False" Visibility="Collapsed" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top" FontSize="11"
|
||||
Padding="5,5,5,5" Margin="0,40,8,0" Background="{DynamicResource CaptionBackground}"
|
||||
Foreground="{DynamicResource WindowTextForeground}">
|
||||
<TextBlock.Inlines>
|
||||
<Run FontWeight="SemiBold">Camera maker</Run><Run>: </Run><Run>SONY</Run>
|
||||
</TextBlock.Inlines>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -23,12 +23,14 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using QuickLook.Annotations;
|
||||
using QuickLook.ExtensionMethods;
|
||||
using QuickLook.Helpers;
|
||||
using QuickLook.Plugin.ImageViewer.Exiv2;
|
||||
|
||||
@@ -59,6 +61,13 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Resources.MergedDictionaries.Clear();
|
||||
|
||||
buttonMeta.Click += (sender, e) =>
|
||||
textMeta.Visibility = textMeta.Visibility == Visibility.Collapsed
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
|
||||
var scale = DpiHelper.GetCurrentScaleFactor();
|
||||
backgroundBrush.Viewport = new Rect(new Size(
|
||||
backgroundBrush.ImageSource.Width / scale.Horizontal,
|
||||
@@ -78,6 +87,28 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
internal ImagePanel(Meta meta) : this()
|
||||
{
|
||||
Meta = meta;
|
||||
|
||||
ShowMeta();
|
||||
}
|
||||
|
||||
private void ShowMeta()
|
||||
{
|
||||
textMeta.Inlines.Clear();
|
||||
Meta.GetSummary().ForEach(m =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(m.Key) || string.IsNullOrWhiteSpace(m.Value))
|
||||
return;
|
||||
|
||||
if (m.Key == "File name" || m.Key == "File size" || m.Key == "MIME type" || m.Key == "Exif comment"
|
||||
|| m.Key == "Image size" || m.Key == "Thumbnail" || m.Key == "Exif comment")
|
||||
return;
|
||||
|
||||
textMeta.Inlines.Add(new Run(m.Key) {FontWeight = FontWeights.SemiBold});
|
||||
textMeta.Inlines.Add(": ");
|
||||
textMeta.Inlines.Add(m.Value);
|
||||
textMeta.Inlines.Add("\r\n");
|
||||
});
|
||||
textMeta.Inlines.Remove(textMeta.Inlines.LastInline);
|
||||
}
|
||||
|
||||
public bool ShowZoomLevelInfo
|
||||
|
@@ -19,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -44,12 +45,12 @@ namespace QuickLook.Plugin.ImageViewer.Exiv2
|
||||
_path = path;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetSummary()
|
||||
public Dictionary<string, string> GetSummary()
|
||||
{
|
||||
if (_summary != null)
|
||||
return _summary;
|
||||
|
||||
return _summary = Run($"\"{_path}\"", ":");
|
||||
return _summary = Run($"\"{_path}\"", ": ");
|
||||
}
|
||||
|
||||
public BitmapSource GetThumbnail(bool autoZoom = false)
|
||||
@@ -120,7 +121,7 @@ namespace QuickLook.Plugin.ImageViewer.Exiv2
|
||||
|
||||
try
|
||||
{
|
||||
var ori = Run($"-g Exif.Image.Orientation -Pkv \"{_path}\"", "\\s");
|
||||
var ori = Run($"-g Exif.Image.Orientation -Pkv \"{_path}\"", "\\s{1,}");
|
||||
|
||||
if (ori?.ContainsKey("Exif.Image.Orientation") == true)
|
||||
_orientation = (OrientationType) int.Parse(ori["Exif.Image.Orientation"]);
|
||||
@@ -172,8 +173,8 @@ namespace QuickLook.Plugin.ImageViewer.Exiv2
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(l))
|
||||
return;
|
||||
var eles = Regex.Split(l, regexSplit + "{1,}");
|
||||
res.Add(eles[0].Trim(), eles[1].Trim());
|
||||
var eles = Regex.Split(l, regexSplit + "");
|
||||
res.Add(eles[0].Trim(), eles.Skip(1).Aggregate((a, b) => $"{a}{regexSplit}{b}"));
|
||||
});
|
||||
|
||||
return res;
|
||||
|
Reference in New Issue
Block a user