Use this to convert all pages of a PDF to JPG:
<?php
$imagick = new Imagick();
$imagick->readImage('myfile.pdf');
$imagick->writeImages('converted.jpg', false);
?>
If you need better quality, try adding $imagick->setResolution(150, 150); before reading the file!
If you experience transparency problems when converting PDF to JPEG (black background), try flattening your file:
<?php
$imagick = new Imagick();
$imagick->readImage('myfile.pdf[0]');
$imagick = $imagick->flattenImages();
$imagick->writeFile('pageone.jpg');
?>
In order to read pages from a PDF-file use [PAGENUMBER] after the filename (pages start from zero!).
Example: Read page #1 from test.pdf
<?php
$imagick = new Imagick();
$imagick->readImage('test.pdf[0]');
$imagick->writeImage('page_one.jpg');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mostrar imagenes</title>
</head>
<body>
<center>
<table border= "2">
<thead>
<tr>
<th>id</th>
<th>Nombre</th>
<th>Imagen</th>
<th>Operaciones</th>
</tr>
</thead>
<tbody>
<?php
// reemplace include ("conexion.php");
require_once 'conexion.php';
$query="SELECT * FROM tabla_imagen";
//agregue este
$conexion=new Conexion();
//
$resultado= $conexion->query($query);
while($row = $resultado->fetch_assoc()){
?>
<tr>
<td><?php echo $row['id']; ?> </td>
<td><?php echo $row['nombre']; ?> </td>
<td><img src="data=image/jpg;base64, <?php echo base64_encode($row['Imagen']); ?>"></td>
<th><a href="#">Modificar</a></th>
<th><a href="#">Eliminar</a></th>
</tr>
<?php
}
?>
</tbody>
</table>
</center>
</body>
</html>