Skip to content

Releases: ordinary9843/ghostscript

v2.4.0

18 Apr 03:03

Choose a tag to compare

New Features

compress() — PDF Compression

Compress a PDF file using Ghostscript's -dPDFSETTINGS with four quality levels:

Quality Description
CompressConstant::SCREEN Smallest file size, lowest quality (screen display)
CompressConstant::EBOOK Balanced size and quality — default
CompressConstant::PRINTER High quality for print (file size may increase)
CompressConstant::PREPRESS Highest quality for press-ready output
use Ordinary9843\Ghostscript;
use Ordinary9843\Constants\CompressConstant;

$ghostscript = new Ghostscript('/usr/bin/gs');
$ghostscript->compress('./file.pdf');                            // ebook (default)
$ghostscript->compress('./file.pdf', CompressConstant::SCREEN); // smallest size

Full Changelog: v2.3.1...v2.4.0

v2.3.1

18 Apr 02:24

Choose a tag to compare

Bug Fixes

  • Fixed SplitHandler off-by-one bug: output files are now correctly named part_1.pdfpart_N.pdf to match Ghostscript's actual output (was part_0.pdfpart_{N-1}.pdf)
  • Fixed MergeHandler undefined variable in catch block; added guard to throw HandlerException when $files is empty
  • Fixed GetTotalPagesHandler undefined variable in catch block
  • Fixed isPdf() in BaseHandler to check file existence before calling mime_content_type(), preventing PHP warnings on non-existent paths
  • Added image type validation in ToImageHandler — only jpeg and png are accepted; invalid types now throw HandlerException

CI

  • Resolved PHPUnit security advisory blocking issue via composer.json audit ignore config

Full Changelog: v2.3.0...v2.3.1

v2.3.0

17 Apr 21:05

Choose a tag to compare

What's Changed

Refactoring

  • Added declare(strict_types=1) to all source files
  • Replaced __call() magic delegation in Ghostscript.php with explicit typed proxy methods for better IDE support and type safety
  • Replaced string-concatenation class resolution in HandlerFactory with an explicit handler map
  • Fixed nullable type hints in exception classes (?BaseException $previous = null)
  • Fixed docblock typo in ConfigTrait (@param int@param string for $tmpPath)

Bug Fixes

  • Fixed SplitHandler off-by-one bug: output files are now correctly named part_1.pdfpart_N.pdf to match Ghostscript's actual output
  • Fixed MergeHandler undefined variable in catch block; added guard for empty $files array
  • Fixed GetTotalPagesHandler undefined variable in catch block
  • Fixed isPdf() in BaseHandler to check file existence before calling mime_content_type(), preventing PHP warnings on non-existent paths
  • Added image type validation in ToImageHandler (only jpeg and png are accepted)

Tests

  • Added edge case tests across all handler test files: empty paths, non-existent files, invalid types, empty arrays, Chinese filenames
  • Added BaseHandlerTest covering isPdf, getTmpFile, clearTmpFiles, and validateBinPath
  • Extended HandlerFactoryTest with uppercase type and unknown type cases
  • Extended PathHelperTest with empty string, backslash, mixed separator, and space cases

CI / GitHub Actions

  • Upgraded actions/checkout to v5.0.1 (node24 native)
  • Upgraded codecov/codecov-action to v6 (resolves Node.js 20 deprecation warning)
  • Removed FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 workaround (no longer needed)
  • Coverage upload now only runs on PHP 8.4
  • Added fail-fast: false to matrix strategy

Full Changelog: v2.2.4...v2.3.0

v2.2.4

31 Jul 16:06

Choose a tag to compare

  • Fix the extension check error in the isPdf() function.
  • Updated version to v2.2.4.

v2.2.3

28 Mar 03:57

Choose a tag to compare

  • Add function clearTmpFIles() to handler interface.
  • Updated version to v2.2.3.

v2.2.2

27 Mar 15:21

Choose a tag to compare

  • Fix merge handler unable to merge does not exist path.
  • Updated version to v2.2.2.

v2.2.1

27 Mar 12:58

Choose a tag to compare

  • Changed image constant name.
  • Updated version to v2.2.1.

v2.2.0

27 Mar 12:52

Choose a tag to compare

  • All handlers will begin to throw exceptions.
  • The exception will provide more detailed information, including the exception code.
  • Add new function for get PDF total pages getTotalPages().
  • Removed multiple functions hasMessages(), getMessages().
  • Removed message constants.
  • Refactor all module & tests.
  • Updated version to v2.2.0.

v2.1.5

19 Feb 14:20

Choose a tag to compare

  • Convert path separator for image & split handlers.
  • Updated version to v2.1.5.

v2.1.4

19 Feb 06:42

Choose a tag to compare

  • Optimize pdf to image.
  • Updated version to v2.1.4.