Containerized REST API for converting PDF documents to images using ImageMagick
2.8K
A lightweight Express.js service that converts PDF files to various image formats base on ImageMagick.
convert command must be available in your PATH)git clone https://github.com/jfabregat/pdf-to-image.git
cd pdf-to-image
npm install
sudo apt-get install imagemagickbrew install imagemagicknpm start
The server will start on port 3000 by default. You can configure the port using the PORT environment variable.
PORT: Server port (default: 3000)VERSION: Application versionBUILD_ID: Build identifierCOMMIT_SHA: Git commit SHAReturns version and uptime information.
Response:
{
"upSince": "2025-03-16T10:00:00.000Z",
"version": "1.0.0",
"buildId": "12345",
"commitSha": "abc123"
}
Converts a PDF file to an image.
Request:
file: PDF file (required)format: Output image format (default: webp)density: DPI for conversion (default: 300)background: Background color (default: white)width: Output width in pixels (default: 800)height: Output height in pixels (default: 600)quality: Output image quality (default: 80%)page: PDF page to convert (default: 1)Example:
curl -X POST http://localhost:3000/convert \
-F "[email protected]" \
-F "format=jpg" \
-F "density=200" \
-F "width=1200" \
-F "page=2"
A Dockerfile is provided to containerize the application:
docker build -t pdf-to-image .
docker run -p 3000:3000 pdf-to-image
Copyright (c) 2025 Joan Fabrégat [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, subject to the conditions in the MIT License.
The Software is provided "as is", without warranty of any kind.
Content type
Image
Digest
sha256:d4ba0b03a…
Size
86.7 MB
Last updated
over 1 year ago
docker pull joanfabregat/pdf2img