1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-22 13:45:02 +00:00

Add support for rendering pdfs.

Also fixed links on recent changes page.
This commit is contained in:
Starbeamrainbowlabs 2016-04-06 16:35:03 +01:00
parent db3b63ac9b
commit c99023d1a4
3 changed files with 29 additions and 5 deletions

View file

@ -2635,17 +2635,29 @@ register_module([
$preview_image->readImage($filepath);
break;
case "application":
if($mime_type == "application/pdf")
{
$preview_image = new imagick();
$preview_image->readImage("{$filepath}[0]");
$preview_image->setResolution(300,300);
$preview_image->setImageColorspace(255);
break;
}
default:
http_response_code(501);
$preview_image = errorimage("Unrecognised file type '$mime_type'.");
header("content-type: image/png");
imagepng($preview_image);
exit();
}
// Scale the image down to the target size
$preview_image->resizeImage($target_size, $target_size, imagick::FILTER_LANCZOS, 1, true);
// Send the completed preview image to the user
header("content-type: $output_mime");
$outputFormat = substr($mime_type, strpos($mime_type, "/") + 1);
$preview_image->setImageFormat($outputFormat);
$preview_image->setImageFormat(substr($output_mime, strpos($output_mime, "/") + 1));
echo($preview_image->getImageBlob());
});

View file

@ -68,7 +68,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
"id": "feature-upload",
"lastupdate": 1459955981,
"lastupdate": 1459956868,
"optional": false
},
{

View file

@ -222,17 +222,29 @@ register_module([
$preview_image->readImage($filepath);
break;
case "application":
if($mime_type == "application/pdf")
{
$preview_image = new imagick();
$preview_image->readImage("{$filepath}[0]");
$preview_image->setResolution(300,300);
$preview_image->setImageColorspace(255);
break;
}
default:
http_response_code(501);
$preview_image = errorimage("Unrecognised file type '$mime_type'.");
header("content-type: image/png");
imagepng($preview_image);
exit();
}
// Scale the image down to the target size
$preview_image->resizeImage($target_size, $target_size, imagick::FILTER_LANCZOS, 1, true);
// Send the completed preview image to the user
header("content-type: $output_mime");
$outputFormat = substr($mime_type, strpos($mime_type, "/") + 1);
$preview_image->setImageFormat($outputFormat);
$preview_image->setImageFormat(substr($output_mime, strpos($output_mime, "/") + 1));
echo($preview_image->getImageBlob());
});