This is a converter pdf to jpeg, written in and for educational and demonstrational purposes.
A backend service for converting pdf documents into jpeg images. It handles file upload, validation, and processing. The results are instantly displayed in an in-browser slider for preview, and are also provided as a downloadable archive containing all images and a portable slider for offline use.
Based on tech stack:
- HTML,
- PHP,
- Laravel,
- Breeze,
- Sanctum,
- ImageMagick,
- MySQL,
- JavaScript,
- Axios,
- CSS,
- TailwindCss,
- Docker,
- Sail,
- Scribe.
-
Secure Document Upload & Validation - Users can upload PDF documents with strict validation for file type, size, and maximum page count. Uploaded files are stored with a unique hashed filename to prevent conflicts and ensure secure storage.
-
High-Quality Conversion Engine - Uses the ImageMagick library to convert each PDF page into a high-resolution JPEG image with optimized compression and automatic portrait orientation correction.
-
Asynchronous Job Processing - Conversion tasks are handled in the background using Laravel Queues, ensuring a responsive user interface and reliable processing of documents.
-
Interactive In-Browser Preview - Converted images are instantly displayed in a built-in, interactive slider, allowing users to navigate between pages directly in their browser.
-
Portable Archive Download - Users can download a self-contained ZIP archive containing all generated JPEG images and a standalone HTML slider for offline viewing and easy sharing.
-
Full User Authentication & Management - Includes secure user registration, login, and profile management powered by Laravel Breeze and Sanctum.
-
Modern Responsive Interface - Features a clean, mobile-friendly UI built with Tailwind CSS with a fully responsive design for all screen sizes, including a light/dark theme toggle for user preference.
- Clone the repository:
git clone [repository-url]- Change directory to project:
cd /path/to/converter-pdf-to-jpeg/- Install php dependencies (temporary ignore ext-imagick if not installed):
composer install --ignore-platform-req=ext-imagick- Create .env file:
cp .env.example .env- Generate application key:
php artisan key:generate-
Run Docker Desktop (with wsl - for Windows only)
-
Run wsl (for Windows only):
wsl- Run Sail:
./vendor/bin/sail up- Add new tab in terminal and connect to container:
docker exec -it converter-pdf-to-jpeg-laravel.test-1 bash- Install php dependencies:
composer install- Run migrations:
php artisan migrate- Install node dependencies:
npm install- Build project:
npm run build-
In browser go to welcome page http://localhost/
-
Register new user on http://localhost/register (enter your name, email, password)
-
Or you can seed database with test user (name: Test User, email: test@example.com, password: password):
php artisan migrate:fresh --seed- Login on http://localhost/login
That's it! Now you can upload pdf documents, convert to jpeg and download zip archives with sliders. For example, you can use pdf documents in tests/Dummies/Documents directory for testing. Thank you!
The application uses Laravel's built-in model pruning to automatically clean up old conversion data and free up disk space.
- What it does: The system automatically removes documents, their generated images, sliders, archive files, and related database records that are older than 24 hours.
- When it runs: Every Sunday at 00:00 (midnight, start of Monday).
- How it works: The
Documentmodel uses theMassPrunabletrait. The scheduled taskmodel:prunefinds and deletes old records. Before deletion, the model'spruning()method ensures all associated files are removed from storage. The process includes error handling to log any file system issues without interrupting the cleanup.
You can trigger the cleanup process manually at any time by running the following command in your terminal:
php artisan model:prune --model=App\\Models\\DocumentTo customize the age threshold for manual cleanup (temporarily), you can:
- Temporarily modify the
prunable()method inapp/Models/Document.phpto use a different time interval (e.g.,now()->subHours(12)for 12 hours). - Run the command above.
The cleanup logic is defined within the Document model itself (app/Models/Document.php):
- Age Threshold: Configured in the
prunable()method (default:now()->subDay()for 24 hours). Modify this method to change how old records must be to be deleted. - File Deletion: Handled in the
pruning()anddeleteDocumentFiles()methods, which safely remove all related files from bothpublicandprivatestorage disks.
The scheduled task is configured in bootstrap/app.php using the withSchedule() method. You can adjust the schedule by modifying the weeklyOn(0, '0:00') call using Laravel's scheduler syntax.
The 'Converter pdf to jpeg' is open-sourced software licensed under the MIT license.
This project uses third-party software components. Their respective licenses can be found in the LICENSE-3rd-party.md file.