Search by

mendesalexandre / tiff-kit-laravel

mendesalexandre

Laravel wrapper for the tiffkit CLI: convert multi-page TIFF to PNG or PDF/A with low memory use.

Package info

github.com/mendesalexandre/tiff-kit-laravel

pkg:composer/mendesalexandre/tiff-kit-laravel

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-12-02 14:26 UTC

This package is auto-updated.

Last update: 2026-12-02 14:49:04 UTC


README

Laravel wrapper for tiffkit: convert large multi-page TIFF files to PDF/A or PNG with very low memory use. The heavy work happens in a separate Rust process, so PHP's memory_limit stops being a problem for big scanned books.

Install

  1. Install the tiffkit binary (Linux x86_64) from the releases and put it on the PATH, e.g. /usr/local/bin/tiffkit:

    curl -fsSL -o /tmp/tiffkit.tar.gz https://github.com/mendesalexandre/tiff-kit/releases/download/v0.5.0/tiffkit-v0.5.0-linux-x86_64.tar.gz
    tar -xzf /tmp/tiffkit.tar.gz -C /usr/local/bin tiffkit
  2. Install the package:

    composer require mendesalexandre/tiff-kit-laravel
    php artisan vendor:publish --tag=tiff-kit-config   # optional

Usage

use TiffKit\Laravel\Facades\TiffKit;

$pages  = TiffKit::info('/data/book.tif');                 // list<PageInfo>: width, height, compression, color
$result = TiffKit::toPdf('/data/book.tif', '/data/out');   // /data/out/book.pdf (PDF/A-3b, PDF 1.7)
$result->pages;    // 554
$result->outputs;  // ['/data/out/book.pdf']

TiffKit::toPdf($file, $dir, pdfaMode: 2);   // PDF/A-2b
TiffKit::toPdf($file, $dir, pdfaMode: 0);   // plain PDF 1.7 (NOT PDF/A)
TiffKit::toPng($file, $dir);                // one grayscale PNG per page

// Several files, in parallel; any case of extension (.tif .TIF .tiff .TIFF)
$files = TiffKit::findTiffs('/data/books');
TiffKit::toPdfMany($files, '/data/out', jobs: 4);

Errors raise TiffKit\Laravel\Exceptions\TiffKitException (with exitCode and stderr). The PDF is only published under its final name when every page was converted; otherwise nothing is left behind. Treat any exception as "not converted" and keep the original TIFF.

Use it inside a queued job for long conversions: the timeout (default 600 s) and parallelism are configurable.

Configuration (config/tiff-kit.php / env)

Env Default Meaning
TIFFKIT_BIN tiffkit Path to the binary
TIFFKIT_TIMEOUT 600 Seconds before the process is killed (0 = no limit)
TIFFKIT_PDFA_MODE 3 2, 3, or 0 for plain PDF
TIFFKIT_DEFAULT_DPI 300 Resolution when the TIFF has none
TIFFKIT_JOBS 1 Parallel files in *Many methods

Notes

  • Digital signing (e.g. ICP-Brasil certificates) is out of scope: sign the produced PDF with your own tool.
  • No OCR / text layer.
  • Tests: composer install && TIFFKIT_BIN=/path/to/tiffkit vendor/bin/phpunit (integration tests are skipped without the binary).

License

MIT.