$tempout"); try{ $image = new Imagick($tempimage); $image->setImageFormat("png"); header('Content-type: text/plain'); echo "data:image/png;base64,".base64_encode ( $image); } catch(Exception $e){ header('Content-type: text/plain'); echo file_get_contents($tempout); } #header('Content-length: '.strlen($output)); unlink($tempimage); unlink($tempout); ?>