Super slim webservice to generate thumbnail images for document files (pdf, odt, doc, docx), video files (mp4, flv, webm, ogv, wmv), 3D Files (ply, obj, stl) and many more using a simple HTTP API.
This is a simple wrapper around algoo/preview-generator.
See the full list of supported file formats.
Boot up the service using the pre-built Docker image:
docker run -p 8000:8000 fpurchess/preview-serviceFor local development or building from source:
# Build and start the service
docker-compose up --build
# Run in detached mode
docker-compose up -dUse the service to create a thumbnail:
# Using a local file
curl -o thumbnail.jpeg -F 'file=file_to_preview.pdf' http://localhost:8000/preview/100x100
# Using a URL (signed S3 URL, etc.)
curl -o thumbnail.jpeg -F 'file_url=https://example.com/file_to_preview.pdf' http://localhost:8000/preview/100x100/tmp/cache/- mount it to persist thumbnail cache/tmp/files/- stores all uploaded files
Here's a full example:
docker run -p 8000:8000 -v /tmp/cache/:/tmp/cache/ -v /tmp/files/:/tmp/files/ fpurchess/preview-serviceReturns 200 OK when the service is up and running.
Accepts one of the following in a multipart/form-data:
- A file to be converted with form name
file - A URL pointing to a file with form name
file_url(e.g., a signed S3 URL)
Returns the converted file as a file response if the conversion is successful.
# Using a local file
curl -o thumbnail.jpeg -F 'file=file_to_preview.pdf' http://localhost:8000/preview/100x100
# Using a URL
curl -o thumbnail.jpeg -F 'file_url=https://example.com/file_to_preview.pdf' http://localhost:8000/preview/100x100
# For video files
curl -o thumbnail.jpeg -F 'file=video.mp4' http://localhost:8000/preview/320x180Creates a JPEG thumbnail image of the provided file with the specified dimensions and stores it in the output file.
- Documents: PDF, DOC, DOCX, ODT, TXT, RTF, PPT, PPTX
- Images: JPG, JPEG, PNG, GIF, BMP, SVG, TIFF, WEBP
- Videos: MP4, FLV, WEBM, OGV, WMV, MOV, AVI, M4V, MPG, MPEG
- Others: See full list of supported formats
Returns a cached converted file if present.
Thanks algoo and all contributors of algoo/preview-generator.
see LICENSE file