How to convert HEIC to PNG in PHP

First, we want to add a reference to our composer.json:

"require": {
"cloudmersive/cloudmersive_document_convert_api_client": "^1.4",

Now, all we need to do is call convertImageImageFormatConvert and pass in “HEIC” as the input file format and “PNG” as the output file format:

require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
$apiInstance = new Swagger\Client\Api\ConvertImageApi(

new GuzzleHttp\Client(),
$format1 = "HEIC";
$format2 = "PNG";
$input_file = "/path/to/file.heic"; // \SplFileObject | Input file to perform the operation on.
try {
$result = $apiInstance->convertImageImageFormatConvert($format1, $format2, $input_file);
} catch (Exception $e) {
echo 'Exception when calling ConvertImageApi->convertImageImageFormatConvert: ', $e->getMessage(), PHP_EOL;

That’s it! It was that easy to convert the HEIC file to PNG in PHP!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store