Need to clean up my code and add the ability to resize the image
You can use PHP's getimagesize() function to get the MIME type.

&lt;?php
include '../../inc/config.php';

if(!isset($_REQUEST['image'])) die('Nenhuma imagem definida!');

$size = isset($_REQUEST['size']) ? $_REQUEST['size'] : 'full';
$image = $_REQUEST['image'];

$img_hash = $PDO-&gt;prepare("SELECT url FROM missionary_photos WHERE hash = :hash");
$img_hash-&gt;bindValue(':hash', $image);
$img_hash-&gt;execute();
$img_hash = $img_hash-&gt;fetchAll(PDO::FETCH_ASSOC);
$img_url = SITE_URL.$img_hash[0]['url'];

$info = getimagesize($img_url);
header('Content-type: '.$info['mime']);

readfile($img_url);