A command-line tool written in Rust for converting HEIC (High Efficiency Image Container) files to PNG or JPG format. Neat-O!
Date: 5 August 2025
- HEIC to PNG/JPG Converter
- Convert HEIC files to PNG or JPG formats
- Command-line interface with flexible options
- Automatic output filename generation
- Support for custom output paths
- Comprehensive help with examples
- Fallback to external tools (ImageMagick, FFmpeg) if needed
For HEIC conversion support, you need one of the following installed:
Option 1: libheif (Recommended)
# macOS
brew install libheif
# Ubuntu/Debian
sudo apt-get install libheif-dev
# Fedora/CentOS
sudo dnf install libheif-develOption 2: ImageMagick
# macOS
brew install imagemagick
# Ubuntu/Debian
sudo apt-get install imagemagick
# Fedora/CentOS
sudo dnf install ImageMagickOption 3: FFmpeg
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpeg
# Fedora/CentOS
sudo dnf install ffmpeg# Clone the repository
git clone <repository-url>
cd heic2png
# Build the project
cargo build --release
# The binary will be available at ./target/release/heic2pngcargo install --path .# Convert HEIC to PNG (default format)
heic2png -i photo.heic
# Convert HEIC to JPG
heic2png -i photo.heic -f jpg
# Specify custom output filename
heic2png -i photo.heic -o converted_photo.png# Convert with custom output directory
heic2png -i /path/to/photo.heic -o /output/dir/converted.jpg -f jpg
# Convert multiple files (shell script)
for file in *.heic; do heic2png -i "$file" -f png; doneOptions:
-i, --input <FILE> Input HEIC file path
-o, --output <FILE> Output file path (optional, will auto-generate if not provided)
-f, --format <FORMAT> Output format: png, jpg, jpeg [default: png]
--bighelp Show detailed help with examples
-h, --help Print help
-V, --version Print version
heic2png --bighelpThis shows comprehensive examples and usage patterns.
The tool attempts conversion in the following order:
- Native image crate support: If the Rust
imagecrate can handle HEIC files directly - ImageMagick: If
convertcommand is available - FFmpeg: If
ffmpegcommand is available - Error with suggestions: If no conversion method is available
- If no output file is specified, the tool generates one based on the input filename
- Example:
photo.heic→photo.png(orphoto.jpgif JPG format is selected) - The tool preserves the original directory unless a different output path is specified
The tool provides helpful error messages and suggestions when:
- Input file doesn't exist
- Input file is not a HEIC/HEIF file
- No conversion tools are available
- Conversion fails
If this tool doesn't work for your setup, you can use:
Command-line alternatives:
# ImageMagick
convert input.heic output.png
# FFmpeg
ffmpeg -i input.heic output.pngGUI alternatives:
- macOS Preview app: Open HEIC → Export as PNG/JPEG
- macOS Photos app: Export as JPEG
- Online converters: convertio.co, cloudconvert.com
clap: Command-line argument parsingimage: Image processing and format conversionanyhow: Error handling
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
[Specify your license here]
This means none of the conversion methods are available. Install one of:
- libheif:
brew install libheif - ImageMagick:
brew install imagemagick - FFmpeg:
brew install ffmpeg
Check that:
- The file path is correct
- You have read permissions for the file
- The file hasn't been moved or deleted
Check that:
- You have write permissions to the output directory
- The output directory exists (the tool will try to create it)
- There's enough disk space
- 0.1.0: Initial release with basic HEIC to PNG/JPG conversion support
Check back often to see the evolution of the project!! This is a work-in-progress. Updates will come periodically.
If you would like to contribute to this project, then please do! For instance, if you see some low-hanging fruit or task that you could easily complete, that could add value to the project, then I would love to have your insight.
Otherwise, please create an Issue for bugs or errors. Since I am a teaching faculty member at Allegheny College, I may not have all the time necessary to quickly fix the bugs. I welcome the OpenSource Community to further the development of this project. Much thanks in advance.
If you appreciate this project, please consider clicking the project's Star button. :-)
