protected function _convert_gif_bmp_to_png($image_url, $type)
    {
        $func_name = "imagecreatefrom$type";

        if (!function_exists($func_name)) {
            if (!method_exists("Dompdf\Helpers", $func_name)) {
                throw new Exception("Function $func_name() not found.  Cannot convert $type image: $image_url.  Please install the image PHP extension.");
            }
            $func_name = "\\Dompdf\\Helpers::" . $func_name;
        }

        set_error_handler(array("\\Dompdf\\Helpers", "record_warnings"));
        $im = call_user_func($func_name, $image_url);

        if ($im) {
            imageinterlace($im, false);

            $tmp_dir = $this->_dompdf->getOptions()->getTempDir();
            $tmp_name = @tempnam($tmp_dir, "{$type}dompdf_img_");
            @unlink($tmp_name);
            $filename = "$tmp_name.png";
            $this->_image_cache[] = $filename;

            imagepng($im, $filename);
            imagedestroy($im);
        } else {
            $filename = Cache::$broken_image;
        }

        restore_error_handler();

        return $filename;
    }