or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

PDF Thumbnail Generator with Quality Control

A utility that generates web-optimized and print-quality thumbnails from PDF documents with precise control over image quality and file size.

Capabilities

Generate web-optimized thumbnails

  • It converts the first page of a PDF to a JPEG thumbnail with dimensions 300x300 pixels, quality set to 75, and saves to a specified output directory @test

Generate high-quality print thumbnails

  • It converts the first page of a PDF to a PNG thumbnail with dimensions 800x800 pixels, quality set to 100, and saves to a specified output directory @test

Generate thumbnails with minimal file size

  • It converts the first page of a PDF to a JPEG thumbnail with dimensions 200x200 pixels, quality set to 50, and saves to a specified output directory @test

Handle different quality levels

  • It converts the same PDF page three times with quality levels 25, 50, and 95, verifying that higher quality produces larger file sizes @test

Implementation

@generates

API

/**
 * Generates a thumbnail from the first page of a PDF with specified quality settings
 *
 * @param {string} pdfPath - Path to the input PDF file
 * @param {Object} options - Configuration options
 * @param {number} options.width - Width of the output thumbnail in pixels
 * @param {number} options.height - Height of the output thumbnail in pixels
 * @param {string} options.format - Output image format ('png' or 'jpg')
 * @param {number} options.quality - Quality level (0-100)
 * @param {string} options.outputDir - Directory where the thumbnail will be saved
 * @param {string} options.filename - Base filename for the output (without extension)
 * @returns {Promise<Object>} Object containing thumbnail metadata (path, size, fileSize)
 */
async function generateThumbnail(pdfPath, options) {
  // IMPLEMENTATION HERE
}

module.exports = { generateThumbnail };

Dependencies { .dependencies }

pdf2pic { .dependency }

Provides PDF to image conversion with quality control support.