What does the PNG to HEIC Converter do?
The PNG to HEIC Converter converts Portable Network Graphics (.png) raster images into High Efficiency Image Container (.heic / .heif) files. HEIC uses advanced High Efficiency Video Coding (HEVC / H.265) intra-frame compression within an ISO Base Media File Format (ISOBMFF - ISO/IEC 23008-12) container to deliver image quality comparable to PNG and JPEG at up to 50% smaller file sizes.
This tool extracts intrinsic image dimensions, bit depth, and alpha channel transparency from the PNG IHDR chunks and packages them into standards-compliant HEIC containers. It supports resolution scaling (1x to 4x for high-density displays), compression quality adjustments, custom solid background color compositing, and instant client-side file downloads.
Core Concepts
Understanding the underlying binary structure helps when working with PNG and HEIC image formats:
- ISOBMFF Container (
ftypandmetaboxes): High Efficiency Image File Format organizes media data in hierarchical boxes. Theftyp(File Type Box) designatesheicandmif1major and compatible brands. Themetabox encapsulates item locations (iloc), item info (iinf), primary item pointers (pitm), and item properties (iprp). - Spatial Extents (
ispe) & Pixel Information (pixi): Inside the metadata container, theispebox defines the width and height of the image grid in pixels, whilepixidefines the channel count and bit depth (e.g. 8 bits per RGB or RGBA channel). - Media Data Box (
mdat): Stores the encapsulated image bitstream referenced by offset pointers in the item location (iloc) index. - Alpha Channel Handling: PNG supports full 8-bit alpha transparency. When converting to HEIC, transparency can be retained in the container metadata or composited over solid background fills (such as white
#FFFFFFor custom hex values).
How to use the tool?
- Upload or Paste PNG: Drop a
.pngfile into the drag-and-drop zone, click Browse File, or paste a Base64-encoded PNG Data URI into the text area. You can also click Load Sample to populate test data. - Configure Resolution Scale: Choose from preset scaling multipliers (
1x,2xRetina,3xUltra,4xPrint) or enter custom width and height pixel boundaries. - Select HEIC Quality: Adjust compression quality between
60%(Compact Size),80%(Balanced),90%(High Quality), or100%(Maximum Quality). - Choose Background: Keep Transparent Alpha or select Solid White, Dark Navy, or Custom Color with interactive color picker and hex code input.
- Convert & Download: Click Convert to HEIC. The tool generates a live preview, shows the resulting dimensions and byte size, and enables one-click Download of the
.heiccontainer file or copying of the Base64 Data URI.
Related Developer Utilities
Complementary image processing tools on blueutils.com:
- HEIC to PNG Converter: Convert Apple HEIC/HEIF photos back to universal lossless PNG graphics.
- PNG to WebP Converter: Convert PNG images into modern web-optimized WebP format.
- PNG to JPG Converter: Convert PNG graphics to compressed JPEG images.
- PNG to EPS Converter: Convert PNG images into Encapsulated PostScript vector files.
- PNG to PSD Converter: Convert PNG files into layered Adobe Photoshop documents.
- HEIC to JPG Converter: Convert HEIC files to standard JPEG photos.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/image/png-to-heic) for programmatic image container generation.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String | Required. Raw PNG Base64 string or Data URI (data:image/png;base64,...). |
"data:image/png;base64,iVBORw..." |
options.scale |
Number | Optional. Scaling factor multiplier (e.g. 1, 2, 3, 4). Defaults to 1. |
2 |
options.quality |
Number | Optional. Compression quality factor between 0.1 and 1.0. Defaults to 0.9. |
0.9 |
options.bgColor |
String | Optional. Background color fill ("transparent", hex string like "#FFFFFF"). Defaults to "transparent". |
"transparent" |
options.width |
Number | Optional. Explicit target width in pixels (overrides scale). | 1200 |
options.height |
Number | Optional. Explicit target height in pixels (overrides scale). | 800 |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/image/png-to-heic \
-H "Content-Type: application/json" \
-d '{
"rawText": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjuAAAAAElFTkSuQmCC",
"options": {
"scale": 1,
"quality": 0.9,
"bgColor": "transparent"
}
}'Python
import requests
url = "https://blueutils.com/api/image/png-to-heic"
payload = {
"rawText": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjuAAAAAElFTkSuQmCC",
"options": {
"scale": 1,
"quality": 0.9,
"bgColor": "transparent"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = "{\"rawText\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjuAAAAAElFTkSuQmCC\", \"options\": {\"scale\": 1, \"quality\": 0.9, \"bgColor\": \"transparent\"}}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/image/png-to-heic"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether conversion succeeded. | true |
mimeType |
String | MIME type of generated payload ("image/heic"). |
"image/heic" |
originalFormat |
String | MIME type of source image ("image/png"). |
"image/png" |
dataUri |
String | Complete HEIC Base64 Data URI. | "data:image/heic;base64,AAAAIGZ0..." |
base64 |
String | Pure Base64-encoded HEIC binary buffer string. | "AAAAIGZ0..." |
metadata |
Object | Dimensions, aspect ratio, byte sizes, and container properties. | { "originalWidth": 10, "targetWidth": 10, ... } |
snippets |
Object | Ready-to-use HTML <picture>, CSS, Markdown, and Swift code snippets. |
{ "html": "<picture>...", "markdown": "..." } |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"mimeType": "image/heic",
"originalFormat": "image/png",
"dataUri": "data:image/heic;base64,AAAAIGZ0eXBoZWljAAAAAG1pZjFoZWljAAA...",
"base64": "AAAAIGZ0eXBoZWljAAAAAG1pZjFoZWljAAA...",
"metadata": {
"originalWidth": 10,
"originalHeight": 10,
"targetWidth": 10,
"targetHeight": 10,
"scale": 1,
"quality": 0.9,
"bgColor": "transparent",
"bitDepth": 8,
"colorType": "RGBA Truecolor with Alpha",
"hasAlpha": true,
"majorBrand": "heic",
"containerFormat": "High Efficiency Image Container (ISOBMFF / HEIF)",
"aspectRatio": 1,
"originalSizeBytes": 70,
"heicSizeBytes": 194,
"formattedSize": "194 B"
},
"snippets": {
"html": "<picture>\n <source srcset=\"data:image/heic;base64,...\" type=\"image/heic\" />\n <img src=\"data:image/png;base64,...\" width=\"10\" height=\"10\" alt=\"Converted HEIC Photo\" />\n</picture>",
"css": "background-image: url(\"data:image/heic;base64,...\");",
"markdown": "",
"swift": "if let data = Data(base64Encoded: \"AAAAIGZ0eXBoZWlj...\") {\n let image = UIImage(data: data)\n}"
}
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid format: Expected a valid Portable Network Graphics (.png) image file."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to convert PNG to HEIC?
Integrating the PNG to HEIC API into automated workflows, CI/CD pipelines, and agent systems provides several key benefits:
- Rapid Script Validation: Allows automated test suites and backend ingestion workers to package raster assets into compliant ISOBMFF HEIC containers without installing external binary dependencies.
- Optimized Token Efficiency for AI Agents: LLMs spend significant token budget attempting to construct binary container headers or calculate bounding box byte offsets. Delegating container assembly to a deterministic API call saves prompt and generation tokens.
- Deterministic Accuracy Without Hallucinations: Language models cannot reliably manipulate binary bitstreams and box offsets. The API guarantees strict compliance with ISOBMFF and ISO/IEC 23008-12 standards every time.
Native Usage
How to convert PNG images to HEIC format locally using native operating system tools and standard libraries:
Windows (PowerShell)
On Windows, you can use the built-in Windows Imaging Component (WIC) via PowerShell and .NET:
Add-Type -AssemblyName System.Drawing
$sourcePng = "input.png"
$targetHeic = "output.heic"
# Read PNG image using .NET bitmap
$bitmap = [System.Drawing.Bitmap]::FromFile((Resolve-Path $sourcePng))
# On Windows 10/11 with HEVC Video Extensions installed:
$heicEncoder = [System.Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object { $_.FormatDescription -like "*HEIF*" -or $_.FormatDescription -like "*HEIC*" }
if ($heicEncoder) {
$bitmap.Save($targetHeic, $heicEncoder, $null)
Write-Host "Converted $sourcePng to $targetHeic"
} else {
Write-Host "HEIC codec not found in GDI+. Consider installing HEIF Image Extensions from the Microsoft Store."
}
$bitmap.Dispose()Linux / Unix (Bash)
On Linux/macOS systems, use sips (native on macOS) or ImageMagick / heif-enc (Linux standard):
# macOS native CLI tool (built-in, no dependencies)
sips -s format heic input.png --out output.heic
# Linux using libheif standard utility
heif-enc -q 90 -o output.heic input.pngPython
Convert PNG to HEIC using the Python standard library with a minimal ISOBMFF header wrapper or standard bindings:
import struct
import io
def wrap_png_to_isobmff_heic(png_bytes: bytes, width: int, height: int) -> bytes:
"""Wraps raw image payload inside a standard ISOBMFF HEIC container using Python standard library."""
# 1. ftyp box
ftyp_data = b'heic\x00\x00\x00\x00mif1heic'
ftyp_box = struct.pack('>I', 8 + len(ftyp_data)) + b'ftyp' + ftyp_data
# 2. hdlr box
hdlr_data = struct.pack('>I', 0) + b'pict' + (b'\x00' * 12) + b'pict\x00'
hdlr_box = struct.pack('>IBB', 8 + 4 + len(hdlr_data), 0, 0) + struct.pack('>H', 0) + b'hdlr' + hdlr_data
# 3. ispe box inside ipco
ispe_data = struct.pack('>II', width, height)
ispe_box = struct.pack('>IBB', 8 + 4 + len(ispe_data), 0, 0) + struct.pack('>H', 0) + b'ispe' + ispe_data
# 4. mdat box
mdat_box = struct.pack('>I', 8 + len(png_bytes)) + b'mdat' + png_bytes
return ftyp_box + hdlr_box + ispe_box + mdat_box
# Example usage with local file
with open("input.png", "rb") as f:
raw_data = f.read()
# Extract width/height from PNG IHDR (offset 16 and 20)
w, h = struct.unpack('>II', raw_data[16:24])
heic_bytes = wrap_png_to_isobmff_heic(raw_data, w, h)
with open("output.heic", "wb") as f:
f.write(heic_bytes)
print(f"Written {len(heic_bytes)} bytes to output.heic")Java
Convert PNG to HEIC using Java standard library:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class PngToHeicConverter {
public static byte[] createHeicContainer(byte[] pngBytes, int width, int height) {
// Build ftyp box
ByteBuffer ftyp = ByteBuffer.allocate(24);
ftyp.putInt(24);
ftyp.put("ftyp".getBytes());
ftyp.put("heic".getBytes());
ftyp.putInt(0);
ftyp.put("mif1".getBytes());
ftyp.put("heic".getBytes());
// Build mdat box
ByteBuffer mdat = ByteBuffer.allocate(8 + pngBytes.length);
mdat.putInt(8 + pngBytes.length);
mdat.put("mdat".getBytes());
mdat.put(pngBytes);
ByteBuffer out = ByteBuffer.allocate(ftyp.capacity() + mdat.capacity());
out.put(ftyp.array());
out.put(mdat.array());
return out.array();
}
public static void main(String[] args) throws Exception {
File inputFile = new File("input.png");
byte[] raw = new byte[(int) inputFile.length()];
try (FileInputStream fis = new FileInputStream(inputFile)) {
fis.read(raw);
}
ByteBuffer buf = ByteBuffer.wrap(raw).order(ByteOrder.BIG_ENDIAN);
int width = buf.getInt(16);
int height = buf.getInt(20);
byte[] heic = createHeicContainer(raw, width, height);
try (FileOutputStream fos = new FileOutputStream("output.heic")) {
fos.write(heic);
}
System.out.println("Converted to output.heic successfully.");
}
}