WINE tips: How to associate IrfanView with an image file type in Linux
December 20, 2010 4 Comments
In my previous post I showed how to install IrfanView with a WINEPREFIX. This time I’m going to show you how to associate IrfanView with a particular image file type so that IrfanView launches and opens a file of that type when you double-click on the file.
IrfanView is an excellent free (but not open-source) application for Windows, and I’ve been using it in Windows since 1997. But there are so many excellent image viewing and editing applications native to Linux that I’ve never needed or wanted to install IrfanView under WINE. GQview, Gwenview, KolourPaint and the GIMP have so far covered all my needs. Nevertheless, IrfanView is my favourite utility for viewing and manipulating image files in Windows, and I can understand why some people may want to run it in Linux.
The usual method of setting file associations in Linux does not work for IrfanView. For example, if you use KDE’s Kickoff > System Settings > File Associations to associate JPG files with IrfanView, IrfanView will indeed launch if you double-click on a JPG file, but you’ll be left staring at an empty IrfanView window, as if you had simply launched IrfanView directly.
However, there is a straightforward work-around for this problem, and it involves the use of a Bash script. You associate the file type with a Bash script that you create specifically to accept a Linux parameter for the file name and convert it to a format that WINE can pass to IrfanView when launching it. Here is how to do it.
I created a text file ~/launch_IrfanView.sh containing the following Bash script:
wine "/home/fitzcarraldo/.wine-irfanview/drive_c/Program Files/IrfanView/i_view32.exe" $File
$File” above may be wrapped around to the next line in your browser window, but note that it is only separated by a space from the rest of the wine command.)
I used a WINEPREFIX of
$HOME/.wine-irfanview/ when I installed IrfanView, so replace “
.wine-irfanview” with “
.wine” if you installed IrfanView without a WINEPREFIX (i.e. if it is installed in the ~/.wine/ directory tree).
I made the file executable:
$ chmod +x /home/fitzcarraldo/launch_IrfanView.sh
I then edited the command for ‘IrfanView 4.27′ in ‘Kickoff’ > ‘System Settings’ > ‘File Associations’ > ‘image’ > ‘jpeg’ > ‘Application Preference Order’ | ‘IrfanView 4.27′ > ‘Edit’ > ‘Application’ to be as follows:
That works fine: when I double-click on a JPG file in a Dolphin window, IrfanView launches and opens the file.
Of course, if you want IrfanView to be the default viewer for PNG files then you would perform the aforementioned steps for ‘Kickoff’ > ‘System Settings’ > ‘File Associations’ > ‘image’ > ‘png’.
As I wrote initially, there are several excellent image viewers and editors for Linux, so I did not keep IrfanView as my default image viewer in Linux. But I have left IrfanView installed under WINE, as I may yet want to use it under Linux at some point.