If you have a Mac and you end up with an annoying .heic or .webp file, there is already a quick way to convert it, in place, to .jpg:

Here is how to get the same behavior on Windows. First, install ImageMagick, which is free and open source. It will automatically add itself to your path, which we need, since we are using its command line interface.

Then create a batch file with this code:


@echo off

set "input_file=%~1"
set "output_file=%~dpn1.jpg"

echo Input file: "%input_file%"
echo Output file: "%output_file%"

magick convert "%input_file%" "%output_file%"

if exist "%output_file%" (
echo Conversion successful.
) else (
echo Conversion failed.
)

Very simple. Then this other batch file below, which you will need to run as administrator, will add a Convert to JPEG item to your context menu. (Remember on Windows nowadays that you need to shift-right click to get the full context menu.) This version takes as an argument the full path of the above batch file, which you can put wherever you want.


@echo off

set "script_path=%~1"

if not exist "%script_path%" (
echo The specified script does not exist: "%script_path%"
pause
exit /b 1
)

echo Adding context menu for .webp files...
reg add "HKEY_CLASSES_ROOT\SystemFileAssociations\.webp\shell\ConvertToJPEG" /f
reg add "HKEY_CLASSES_ROOT\SystemFileAssociations\.webp\shell\ConvertToJPEG\command" /ve /t REG_EXPAND_SZ /d "\"%script_path%\" \"%%1\"" /f

echo Adding context menu for .heic files...
reg add "HKEY_CLASSES_ROOT\SystemFileAssociations\.heic\shell\ConvertToJPEG" /f
reg add "HKEY_CLASSES_ROOT\SystemFileAssociations\.heic\shell\ConvertToJPEG\command" /ve /t REG_EXPAND_SZ /d "\"%script_path%\" \"%%1\"" /f

echo Context menu integration complete.
pause

Now, you should see this:

And that’s it. Thank you Claude.AI for help with Windows registry nonsense.


Tags
Posts

Date
April 5, 2024