This sample source code can be used to convert PDF to image(BMP, JPEG, PNG, TIFF, GIF) in PHP using ByteScout Cloud API (low level). You can set such parameters as image resolution, quality, and image output format.

You can also find PDF to Image conversion code samples for other languages here: Java, jQuery, and pure JavaScript.

Sample.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PDF Renderer Cloud API Example</title>
</head>

<body>

    <form name="form1" enctype="multipart/form-data" method="post" action="render_pdf.php">
        <p>
            <label>Copy-paste your API Key for Bytescout.IO here</label>
            <input type="text" name="apiKey" placeholder="API Key"/>
        </p>
        <p>
            <label>Input File</label>
            <input type="hidden" name="MAX_FILE_SIZE" value="8000000"/>
            <input type="file" name="file"/>
        </p>
        <p>
            <label>Output Image Format</label>
            <select name="rasterOutputFormat">
                <option value="BMP">BMP</option>
                <option value="JPEG">JPEG</option>
                <option value="PNG" selected="selected">PNG</option>
                <option value="TIFF">TIFF</option>
                <option value="GIF">GIF</option>
            </select>
        </p>
        <p>
            <label>Rendering Resolution, DPI</label>
            <input type="number" name="resolution" value="300">
        </p>
        <p>
            <label>Page Index (zero-based)</label>
            <input type="number" name="pageIndex" value="0">
        </p>
        <input type="submit" name="submit" value="Proceed" />
    </form>

</body>
</html>

render_pdf.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PDF Renderer Results</title>
</head>
<body>

<?php 

// Get submitted form data
$apiKey = $_POST["apiKey"];
$rasterOutputFormat = $_POST["rasterOutputFormat"];
$resolution = $_POST["resolution"];
$pageIndex = $_POST["pageIndex"];


// 1. UPLOAD FILE

// Create File API URL
$url = "https://bytescout.io/api/v1/file/upload?apiKey=" . $apiKey; // Get your API key at http://www.bytescout.io/

// Create request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
    "file" => "@" . $_FILES["file"]["tmp_name"] . ";filename=" . $_FILES["file"]["name"]
    ));
// Execute request
$result = curl_exec($curl);

if (curl_errno($curl))
{
    // Display request error
    echo "Error: " . curl_error($curl);
}
else // Display request results
{
    $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($status_code == 200)
    {
        // 2. RENDER DOCUMENT
        RenderPDF($apiKey, $rasterOutputFormat, $resolution, $pageIndex, $result);
    }
    else
    {
        // Display service reported error
        echo "<p>Status code: " . $status_code . "</p>"; 
        echo "<p>" . $result . "</p>"; 
    }
}

// Cleanup
curl_close($curl);


function RenderPDF($apiKey, $rasterOutputFormat, $resolution, $pageIndex, $uploadedFileId) 
{
    // Create PDF Renderer API URL
    $url = "https://bytescout.io/api/v1/pdfrenderer/render?apiKey=" . $apiKey;
    
    // Create PDF Renderer  options
    $options = array(
        "properties" => array(
            "pageIndex" => $pageIndex,
            "resolution" => $resolution,
            "jpegQuality" => 85,
            "rasterOutputFormat" => $rasterOutputFormat
            ),
        "inputType" => "fileId",
        "input" => $uploadedFileId,
        "outputType" => "link"
        );

    // Create request
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($options));
    // Execute request
    $result = curl_exec($curl);
    
    if (curl_errno($curl))
    {
        // Display request error
        echo "Error: " . curl_error($curl);
    }
    else // Display request results
    {
        $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if ($status_code == 200)
        {
            // Display decoding results
            echo "<div><h2>Result:</h2><img src=" . $result . "></div>";
        }
        else
        {
            // Display service reported errors
            echo "<p>Status code: " . $status_code . "</p>"; 
            echo "<p>" . $result . "</p>"; 
        }
    }
    
    // Cleanup
    curl_close($curl);
}

?>

</body>
</html>