Add HEIF/AVIF EXIF metadata extraction and UI support (#44466)

- Support EXIF extraction from HEIF/HEIC and AVIF images by detecting
container format and using correct WIC metadata paths.
- Extend supported file extensions to include .heic, .heif, and .avif.
- Add unit tests and test data for HEIF/AVIF extraction, with graceful
handling if required Windows Store extensions are missing.
- Update PowerRename settings UI to show HEIF/AVIF extension status and
provide install buttons.
- Extend ViewModel to detect/install required extensions and expose
status for binding.

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #43758
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Co-authored-by: Yu Leng <yuleng@microsoft.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
moooyo
2026-01-08 11:18:47 +08:00
committed by GitHub
parent 9c58574484
commit 72fc8288eb
12 changed files with 724 additions and 46 deletions

View File

@@ -0,0 +1,98 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using ManagedCommon;
using Windows.Management.Deployment;
using Windows.System;
namespace Microsoft.PowerToys.Settings.UI.Helpers
{
/// <summary>
/// Helper class to manage installation status and installation command for a Microsoft Store extension.
/// </summary>
public class StoreExtensionHelper : INotifyPropertyChanged
{
private readonly string _packageFamilyName;
private readonly string _storeUri;
private readonly string _extensionName;
private bool? _isInstalled;
public event PropertyChangedEventHandler PropertyChanged;
public StoreExtensionHelper(string packageFamilyName, string storeUri, string extensionName)
{
_packageFamilyName = packageFamilyName ?? throw new ArgumentNullException(nameof(packageFamilyName));
_storeUri = storeUri ?? throw new ArgumentNullException(nameof(storeUri));
_extensionName = extensionName ?? throw new ArgumentNullException(nameof(extensionName));
InstallCommand = new AsyncCommand(InstallExtensionAsync);
}
/// <summary>
/// Gets a value indicating whether the extension is installed.
/// </summary>
public bool IsInstalled
{
get
{
if (!_isInstalled.HasValue)
{
_isInstalled = CheckExtensionInstalled();
}
return _isInstalled.Value;
}
}
/// <summary>
/// Gets the command to install the extension.
/// </summary>
public ICommand InstallCommand { get; }
/// <summary>
/// Refreshes the installation status of the extension.
/// </summary>
public void RefreshStatus()
{
_isInstalled = null;
OnPropertyChanged(nameof(IsInstalled));
}
private bool CheckExtensionInstalled()
{
try
{
var packageManager = new PackageManager();
var packages = packageManager.FindPackagesForUser(string.Empty, _packageFamilyName);
return packages.Any();
}
catch (Exception ex)
{
Logger.LogError($"Failed to check extension installation status: {_packageFamilyName}", ex);
return false;
}
}
private async Task InstallExtensionAsync()
{
try
{
await Launcher.LaunchUriAsync(new Uri(_storeUri));
}
catch (Exception ex)
{
Logger.LogError($"Failed to open {_extensionName} extension store page", ex);
}
}
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -7,10 +7,18 @@
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
xmlns:ui="using:CommunityToolkit.WinUI"
AutomationProperties.LandmarkType="Main"
mc:Ignorable="d">
<local:NavigablePage.Resources>
<tkconverters:BoolToVisibilityConverter
x:Key="BoolToInvertedVisibilityConverter"
FalseValue="Visible"
TrueValue="Collapsed" />
</local:NavigablePage.Resources>
<controls:SettingsPageControl x:Uid="PowerRename" ModuleImageSource="ms-appx:///Assets/Settings/Modules/PowerRename.png">
<controls:SettingsPageControl.ModuleContent>
<StackPanel
@@ -97,6 +105,48 @@
IsOn="{x:Bind ViewModel.UseBoostLib, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="PowerRename_ExtensionsHeader" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard
Name="PowerRenameHeifExtension"
x:Uid="PowerRename_HeifExtension"
HeaderIcon="{ui:FontIcon Glyph=&#xEB9F;}">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon
VerticalAlignment="Center"
Foreground="{ThemeResource SystemFillColorSuccessBrush}"
Glyph="&#xEC61;"
Visibility="{x:Bind ViewModel.IsHeifExtensionInstalled, Mode=OneWay}" />
<TextBlock
x:Uid="PowerRename_HeifExtension_Installed"
VerticalAlignment="Center"
Visibility="{x:Bind ViewModel.IsHeifExtensionInstalled, Mode=OneWay}" />
<Button
x:Uid="PowerRename_HeifExtension_Install"
Command="{x:Bind ViewModel.InstallHeifExtensionCommand}"
Visibility="{x:Bind ViewModel.IsHeifExtensionInstalled, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}" />
</StackPanel>
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
Name="PowerRenameAvifExtension"
x:Uid="PowerRename_AvifExtension"
HeaderIcon="{ui:FontIcon Glyph=&#xEB9F;}">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon
VerticalAlignment="Center"
Foreground="{ThemeResource SystemFillColorSuccessBrush}"
Glyph="&#xEC61;"
Visibility="{x:Bind ViewModel.IsAvifExtensionInstalled, Mode=OneWay}" />
<TextBlock
x:Uid="PowerRename_AvifExtension_Installed"
VerticalAlignment="Center"
Visibility="{x:Bind ViewModel.IsAvifExtensionInstalled, Mode=OneWay}" />
<Button
x:Uid="PowerRename_AvifExtension_Install"
Command="{x:Bind ViewModel.InstallAvifExtensionCommand}"
Visibility="{x:Bind ViewModel.IsAvifExtensionInstalled, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}" />
</StackPanel>
</tkcontrols:SettingsCard>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>

View File

@@ -1698,6 +1698,35 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<value>Provides extended features but may use different regex syntax</value>
<comment>Boost is a product name, should not be translated</comment>
</data>
<data name="PowerRename_ExtensionsHeader.Header" xml:space="preserve">
<value>Extensions</value>
</data>
<data name="PowerRename_HeifExtension.Header" xml:space="preserve">
<value>HEIF image metadata extraction</value>
</data>
<data name="PowerRename_HeifExtension.Description" xml:space="preserve">
<value>Requires HEIF Image Extensions from Microsoft Store to extract metadata from HEIC/HEIF files</value>
<comment>HEIF is a file format name, do not translate</comment>
</data>
<data name="PowerRename_HeifExtension_Install.Content" xml:space="preserve">
<value>Install from Microsoft Store</value>
</data>
<data name="PowerRename_HeifExtension_Installed.Text" xml:space="preserve">
<value>Installed</value>
</data>
<data name="PowerRename_AvifExtension.Header" xml:space="preserve">
<value>AVIF image metadata extraction</value>
</data>
<data name="PowerRename_AvifExtension.Description" xml:space="preserve">
<value>Requires AV1 Video Extension from Microsoft Store to extract metadata from AVIF files</value>
<comment>AVIF is a file format name, do not translate</comment>
</data>
<data name="PowerRename_AvifExtension_Install.Content" xml:space="preserve">
<value>Install from Microsoft Store</value>
</data>
<data name="PowerRename_AvifExtension_Installed.Text" xml:space="preserve">
<value>Installed</value>
</data>
<data name="MadeWithOssLove.Text" xml:space="preserve">
<value>Made with 💗 by Microsoft and the PowerToys community.</value>
</data>

View File

@@ -5,9 +5,12 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Input;
using global::PowerToys.GPOWrapper;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
@@ -67,6 +70,17 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_autoComplete = Settings.Properties.MRUEnabled.Value;
_powerRenameUseBoostLib = Settings.Properties.UseBoostLib.Value;
// Initialize extension helpers
HeifExtension = new StoreExtensionHelper(
"Microsoft.HEIFImageExtension_8wekyb3d8bbwe",
"ms-windows-store://pdp/?ProductId=9PMMSR1CGPWG",
"HEIF");
AvifExtension = new StoreExtensionHelper(
"Microsoft.AV1VideoExtension_8wekyb3d8bbwe",
"ms-windows-store://pdp/?ProductId=9MVZQVXJBQ9V",
"AV1");
InitializeEnabledValue();
}
@@ -270,5 +284,31 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(GlobalAndMruEnabled));
}
// Store extension helpers
public StoreExtensionHelper HeifExtension { get; private set; }
public StoreExtensionHelper AvifExtension { get; private set; }
// Convenience properties for XAML binding
public bool IsHeifExtensionInstalled => HeifExtension.IsInstalled;
public bool IsAvifExtensionInstalled => AvifExtension.IsInstalled;
public ICommand InstallHeifExtensionCommand => HeifExtension.InstallCommand;
public ICommand InstallAvifExtensionCommand => AvifExtension.InstallCommand;
public void RefreshHeifExtensionStatus()
{
HeifExtension.RefreshStatus();
OnPropertyChanged(nameof(IsHeifExtensionInstalled));
}
public void RefreshAvifExtensionStatus()
{
AvifExtension.RefreshStatus();
OnPropertyChanged(nameof(IsAvifExtensionInstalled));
}
}
}