Open Whatever Files in Affinity Photo v2 from XNView MP

Hello koalas,

Beginning of December 2022, I just bought the "Affinity v2 Universal License" on the official website https://affinity.serif.com/ and even I am not a hardcore user of all Affinity applications I can say without hesitation that it is a wonderful alternative as Adobe products such as Photoshop and Lightroom.

I used to enjoy the interaction between PS and LR in the past and few years later I wondered if I could get back this workflow with Affinity Photo and another software...

The short answer is yes it is possible but it's not perfect yet. Anyway to make long story short I've decided to use "XNView MP" as my DAM (Digital Asset Management) or should I say as my photo library.

Unfortunately, the interaction between XNView MP and Affinity Photo is not perfect yet. I had to fight for a while to make it works as I wanted.

Table of Contents

My Problems

First problem:
I couldn't open Affinity Photo v2 files (.afphoto) from XNView MP.

Second problem:
I couldn't open my raw (.nef) files with Affinity Photo v2 without changing my "Default app" for my raw files.

The Solutions

Here are what I did...

Step 1 - Install the apps

XNView MP:
Download and install XNView MP from the official website: https://www.xnview.com/en/xnviewmp/

Affinity Photo:
You have to use Microsoft Store to install it. Here is the link: https://apps.microsoft.com/store/detail/affinity-photo-2/9P8DVF1XW02V

Step 2 - Show Affinity Photo files in XNView MP (First Problem Solved)

Open "XNView MP", then go to the menu Tools/Settings/General and tick "Show all graphic formats".

Restart XNView MP and you should be able to visualize Affinity Photo files (.afphoto).

The result:

Step 3 - Understand How Affinity Photo is Installed (from Microsoft Store)

This step is important to understand how I've fixed the problem and it's always good to understand more about how things work! Isn't it? 😊

When you install an app from the Microsoft Store, the app is installed on:

C:\Program Files\WindowsApps\[Application Folder]

Here is the path for Affinity Photo:

C:\Program Files\WindowsApps\SerifEuropeLtd.AffinityPhoto2_2.0.0.1640_x64__3cqzy0nppv2rt

The executable "Photo.exe" to run the application is on:

"C:\Program Files\WindowsApps\SerifEuropeLtd.AffinityPhoto2_2.0.0.1640_x64__3cqzy0nppv2rt\App\Photo.exe"

Windows also adds an alias on (not fro all apps):

"C:\Users\[USERNAME]\AppData\Local\Microsoft\WindowsApps\SerifEuropeLtd.AffinityPhoto2_3cqzy0nppv2rt\AffinityPhoto2.exe"

And if "App execution aliases" for Affinity Photo has been enabled, another one on:

"C:\Users\[USERNAME]\AppData\Local\Microsoft\WindowsApps\AffinityPhoto2.exe"

I know what you think... It's messy the way it is! And I totally agree with this thinking 😊.

We have the real EXE (Photo.exe) and 2 aliases (AffinityPhoto2.exe) that we can use with XNView MP but without any further secret. None of them work! OMG!

Unfortunately, and for an unknown reason it doesn't work. The EXE can be linked but doesn't open anything and both aliases cannot be linked because XNView MP doesn't recognized them as real executables.

The question is what to do to be able to add "Affinity Photo" executable in XNView MP as a "Configured Program"?

Step 4 - Create an Alternative Affinity Photo Executable

Important:  the executable created is not an official one and it is not signed! Some antiviruses will alert you that it could be a dangerous file and it's true it could be in some situation but not here.

Let me explain before to complain...

The main objective is to add "Affinity Photo" as a configured program (also called external program) in XNView MP. Then, you would be able to open whatever type of files you want with Affinity Photo. Such as .jpg .png .nef (raw) .crw (raw) and so on without changing the associations on your Windows.

For example, you use to open the .jpg and .png with your "Photo" app or with another viewer but time to time you want to open them with Affinity Photo to edit them.

So here is the way to create a specific executable with PowerShell:

Firstly, create a PowerShell file and named it "run_affinityphoto2.ps1" (you can use the name that suit you the best).

Add the following script and save your file:

# Run Affinity Photo 2 with PowerShell

function runaffinityphoto2 {
    param (
        [String]$FilePath
    )

    Start-Process -FilePath AffinityPhoto2.exe -ArgumentList $FilePath
}

runaffinityphoto2 -FilePath """$args"""

Now, we are going to use a tiny app (PowerShell module) to convert the PowerShell script into an executable (.exe).

Open a PowerShell Windows as admin.

Install the module "ps2exe" with the command:

Install-Module -Name ps2exe

Then open the GUI for ps2exe with the command:

Win-PS2EXE

You should see a Window popped-up:

Here is my configuration:

Source file:path to the PowerShell file (run_affinityphoto2.ps1).
Target file:path to the folder containing the PowerShell file (run_affinityphoto2.ps1).
Icon file: [Optional]select an icon for your executable.
Version: [Optional]1.0
File description: [Optional]Run Affinity Photo v2
Product name: [Optional]run_affinityphoto_v2
Copyright: [Optional]LearningKoala
Tick [✔]Compile a graphic windows program (parameter -noConsole)

Click on "Compile" when the configuration is done.

You should have these files now (the .ico file is optional):

Step 5 - Configuration XNView MP with the new executable (.exe)

Copy your new executable (run_affinityphoto2.exe) on:

C:\Users\[USERNAME]\AppData\Local\Microsoft\WindowsApps

It should be like this:

Open XNView MP.

Right-click on an image and go to "Open with/Configure program...".

Click on "Add..." and select the new executable (run_affinityphoto2.exe).

You should have this:

Now if you select an image (.jpg, .png, .bmp,...) or a raw file (.nef, .crw,...) and press "Alt + 1" your file opens with "Affinity Photo v2" even if the type of file is linked to another application (problem 2 solved 🙂).

Congratulations to you if you had enough patience to read this article.
I hope it was interesting and helpful.

Didier

Sources used

NameLink
Adam The Automator - The De Facto Guide for Converting a PS1 to EXE (7 Ways)Link
Affinity Forum - Not able to start Affinity Photo 2 from DxO, XNView MP, ART and Raw TherapeeLink
PowerShell FunctionsLink

 

 

 

 

 

 

 

Â