A PowerShell script to convert HEIC files to JPEG using ImageMagick. This tool is designed to be simple, efficient, and user-friendly, offering features such as unique filename generation, detailed conversion statistics (file sizes, conversion time), a progress bar, and configurable options for logging and moving original files to the Recycle Bin.
-
HEIC to JPEG Conversion:
Converts HEIC images to JPEG format using ImageMagick. -
Unique Filename Generation:
Automatically appends a numeric suffix if an output file with the intended name already exists, similar to Windows file naming. -
Detailed Conversion Metrics:
Displays the original and new file sizes (in MB) with percentage change (indicating if the size increased or reduced), the conversion time for each file, and the overall runtime. -
Progress Feedback:
Shows a progress bar that updates as files are processed. -
Configurable Options:
- Recursion: Process files only in the specified directory or include subdirectories using the
-Recurse
switch. - Move to Trash: By default, the original HEIC files are moved to the Recycle Bin after conversion. Use
-MoveToTrash:$false
to keep them in place. - Logging: Optionally generate log files (
conversion.log
andconversion_errors.log
) in the script’s directory with the-EnableLogging
switch.
- Recursion: Process files only in the specified directory or include subdirectories using the
-
Parameter Summary:
A neatly formatted table is displayed before conversion, allowing you to review your settings.
-
PowerShell 7 or later
This script uses features available in PowerShell 7+. -
ImageMagick
The script relies on themagick
command. Ensure ImageMagick is installed and that themagick
command is available in your system’s PATH.
- Clone or Download the Repository:
git clone https://github.com/andreas-glaser/PS-HEIC2JPG-Converter.git
- Ensure Dependencies Are Met:
- Install PowerShell 7+.
- Install ImageMagick and make sure the
magick
command is in your PATH.
- Navigate to the Repository Folder:
Open PowerShell and change to the repository directory.
Run the script using the following syntax:
.\heic2jpg.ps1 -TargetDirectory "Path\To\Your\Directory" [-Recurse] [-MoveToTrash] [-EnableLogging] [other parameters]
-
Convert files in a directory (non-recursive, with default move to trash):
.\heic2jpg.ps1 -TargetDirectory "C:\Images\HEIC"
-
Convert files in a directory without moving originals:
.\heic2jpg.ps1 -TargetDirectory "C:\Images\HEIC" -MoveToTrash:$false
-
Convert files recursively with logging enabled:
.\heic2jpg.ps1 -TargetDirectory "C:\Images\HEIC" -Recurse -EnableLogging
Parameter | Type | Default | Description |
---|---|---|---|
-TargetDirectory |
String | (Required) | The directory containing HEIC files to convert. |
-Recurse |
Switch | Off | Process files in subdirectories. |
-MoveToTrash |
Boolean | $true |
Move the original HEIC file to the Recycle Bin after conversion. Use -MoveToTrash:$false to keep the file. |
-EnableLogging |
Switch | Off | If specified, enable logging. Creates conversion.log and conversion_errors.log in the script's directory. |
-InputExtension |
String | "*.heic" |
File extension filter for input files. |
-OutputExtension |
String | ".jpg" |
Extension for output files. |
-Quality |
Int | 95 |
JPEG quality for conversion (1 = lowest, 100 = highest). |
-
File Discovery:
The script scans the target directory (and subdirectories if-Recurse
is provided) for files matching the input extension. -
Parameter Summary & File Listing:
It displays a neatly formatted table of conversion parameters and lists the files to be converted (up to 10 files). -
Conversion Process:
For each file, the script:- Generates a unique output filename if needed.
- Calls ImageMagick (
magick
) to convert the file to JPEG using the specified quality. - Logs output and errors if logging is enabled.
- Calculates and displays the original file size, new file size, and the percentage change (indicating whether the size increased or reduced).
- Reports the conversion time for each file.
-
Overall Metrics:
Once all files are processed, the script displays the total runtime.
This project is licensed under the MIT License. See the LICENSE file for details.