How to Convert HEIC to JPG using PowerShell

If you’ve ever tried to open your iPhone photos on a Windows PC, you might’ve encountered that mysterious .heic extension. It is not always easy to work with outside the Apple ecosystem. If you are looking for an easy way to convert those HEIC files to the more universally friendly JPG format, you’ve come to the right place.

In this tutorial, I’ll walk you through how to convert your HEIC photos to JPG using PowerShell — quickly, efficiently, and without any need for complicated software or online converters.

HEIC stands for High-Efficiency Image Codec. Apple started using it to help pack more photos on your iPhone without sacrificing quality. Smart, right? But… that efficiency comes at a price — not every Windows app or website gets along with HEIC files yet.

Make sure, you have Windows 10 or 11 with PowerShell version 5.1 or above (most modern versions fit this). Run this command to check your version quickly:

$PSVersionTable.PSVersion

The HEIF Image Extensions are installed from the Microsoft Store. This little add-on lets Windows peek inside HEIC files.

Method 1: Native PowerShell Magic with .NET

Let’s start simple. Windows PowerShell can use a built-in .NET library to open HEIC files (thanks to that HEIF extension) and save them as JPG. Here’s how:

Step 1: Open PowerShell as Administrator

Hit your Start menu, type “PowerShell,” right-click it, and pick “Run as Administrator.” Trust me, it will save you permission headaches later.

Step 2: Make Sure HEIC Opens Smoothly

Double-click a HEIC file in File Explorer. If it opens, you’re good to go. If not, check that the HEIF Image Extensions are installed correctly.

Step 3: Run This Conversion Script

Copy and paste this in your PowerShell window — just update the folder paths for your system:

# Where are your HEIC files?
$sourceFolder = "C:\Users\Bijay\Pictures\HEIC"
# Where do you want JPGs to go?
$destinationFolder = "C:\Users\Bijay\Pictures\JPG"

# Creates destination folder if needed
if (-not (Test-Path $destinationFolder)) {
    New-Item -ItemType Directory -Path $destinationFolder
}

# Convert each HEIC to JPG
Get-ChildItem -Path $sourceFolder -Filter *.heic | ForEach-Object {
    $fileName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
    $outputFile = Join-Path $destinationFolder "$fileName.jpg"
    
    $image = [System.Drawing.Image]::FromFile($_.FullName)
    $image.Save($outputFile, [System.Drawing.Imaging.ImageFormat]::Jpeg)
    $image.Dispose()

    Write-Host "Converted: $($_.Name) to $fileName.jpg"
}

Hit Enter, watch the magic happen, and check your JPG folder.

Check out: Convert Bytes to GB in PowerShell

Method 2: Convert using ImageMagick

If you want a more bulletproof solution or need to convert on a system without HEIF support, ImageMagick is your friend.

Step 1: Install ImageMagick

The easiest way is the Windows Package Manager. Open PowerShell and type:

winget install ImageMagick.ImageMagick

If winget isn’t ready on your system, download it manually from the ImageMagick website.

Step 2: Convert a Single File

Try converting one file first:

magick "C:\Photos\sample.heic" "C:\Photos\sample.jpg"

If the JPG appears correctly, you’re ready for batch mode!

Step 3: Batch Convert All Your HEIC Photos

Here’s a snippet to convert every HEIC in a folder automatically:

$source = "C:\Photos\HEIC"
$destination = "C:\Photos\JPG"

if (-not (Test-Path $destination)) {
    New-Item -ItemType Directory -Path $destination
}

Get-ChildItem "$source\*.heic" | ForEach-Object {
    $jpgPath = Join-Path $destination ($_.BaseName + ".jpg")
    magick $_.FullName $jpgPath
    Write-Host "Converted: $($_.Name) to $($jpgPath)"
}

Check out Convert JSON to XML using PowerShell

Create a Reusable Function

You can also create a reusable function like below:

function Convert-HEICtoJPG {
    param (
        [string]$InputFolder,
        [string]$OutputFolder
    )

    if (-not (Test-Path $OutputFolder)) {
        New-Item -ItemType Directory -Path $OutputFolder
    }

    Get-ChildItem -Path $InputFolder -Filter *.heic | ForEach-Object {
        $output = Join-Path $OutputFolder ($_.BaseName + ".jpg")
        magick $_.FullName $output
        Write-Host "Converted: $($_.Name) to $output"
    }
}

# Usage example:
Convert-HEICtoJPG -InputFolder "C:\Photos\HEIC" -OutputFolder "C:\Photos\JPG"

Read PowerShell Convert XML to Object

Error Handling and Troubleshooting

Even with simple scripts, some errors can occur. Here’s how to address common ones:

  • Cannot load or open HEIC file: Ensure HEIF Image Extensions are installed correctly and your system supports HEIC.
  • Permission denied: Run PowerShell as Administrator or adjust folder permissions.
  • Command ‘magick’ not recognized: Confirm ImageMagick was installed correctly and the executable is in your system PATH.
  • Use this snippet to gracefully catch errors and output messages:
try {
    # Conversion code here
}
catch {
    Write-Host "Conversion failed: $($_.Exception.Message)"
}

In this tutorial, I explained how to convert HEIC to JPG using PowerShell using the built-in .NET method and ImageMagick approach.

You may also like:

Leave a Comment

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.