ImageMagick - writeImage输出产生8位深度图像而不是24位深度图像

I am really new to this ImageMagick & GhostScript thus, I am confused what I have done wrong. I am trying to convert the cover page of the PDF to JPG, but some of the writeImage output, produce colored once - 24bit, and most produce mono-coloured - 8bit(Which I don't want).

My code is:


<html>
<head>
</head>
<body>
    <form action="upload.php" method="post" enctype="multipart/form-data">
        <input type="file" id="pdf" name="file" accept=".pdf"/>
        <input type="file" id="imagePDF" style="display:none">
        <input type="submit" value="upload"/>
    </form>
</body>


<?php
if(isset($_FILES['file'])){

    //Save file to directory
    $file = $_FILES['file'];
    $file_destination = "files/";
    //File properties
    $file_name = $file['name'];
    $file_tmp = $file['tmp_name'];
    $file_size = $file['size'];
    $file_error = $file['error'];

    //Work out the file extension
    $file_ext = explode('.', $file_name);
    $file_ext = strtolower(end($file_ext));

    $allowed = array('pdf');

    if(in_array($file_ext, $allowed)){
        if($file_error === 0){
            if($file_size <= 63000000){
                //File destination relative to upload.php
                $pdfWithPath = $file_destination . $file_name;
                if(move_uploaded_file($file_tmp, $pdfWithPath)){
                    echo("File uploaded: <br>");
                    echo $pdfWithPath;
                }

            }
        }
    }

    //Create thumbnail and save to directory
    $thumb_name = $file_name . ".jpg";
    $thumb_destination = "pdfThumb/";
    $thumb_path = $thumb_destination . $thumb_name;
    $thumb_first_page = $pdfWithPath . "[0]";

    $image = new Imagick();
    $image->readImage(__DIR__ . DIRECTORY_SEPARATOR . $thumb_first_page);
    $image->writeImage(__DIR__ . DIRECTORY_SEPARATOR .'pdfThumb/'.$thumb_name);
    $image->destroy();
    echo("Done");
}
?>

<html>
    <head>
        <!--Display image on screen -->
        <img src="<?php echo $thumb_path; ?>"/>
    </head>
    <body>
    </body>
</html>

The idea of this code is to upload the pdf and store it into the folder 'files' Then to create the thumbnail of the PDF file, it will retrieve the PDF from the folder 'files' and produce an image, saving the image to the folder 'pdfThumb'


I have 2 outcomes for this writeImage, colored and mono-coloured shown below

Mono-coloured image produced

Coloured image produce


I want to make all the images produced by the writeImage output to be all colored. How should I improve my code?