Releases: ordinary9843/ghostscript
Releases · ordinary9843/ghostscript
v2.4.0
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 sizeFull Changelog: v2.3.1...v2.4.0
v2.3.1
Bug Fixes
- Fixed
SplitHandleroff-by-one bug: output files are now correctly namedpart_1.pdf–part_N.pdfto match Ghostscript's actual output (waspart_0.pdf–part_{N-1}.pdf) - Fixed
MergeHandlerundefined variable in catch block; added guard to throwHandlerExceptionwhen$filesis empty - Fixed
GetTotalPagesHandlerundefined variable in catch block - Fixed
isPdf()inBaseHandlerto check file existence before callingmime_content_type(), preventing PHP warnings on non-existent paths - Added image type validation in
ToImageHandler— onlyjpegandpngare accepted; invalid types now throwHandlerException
CI
- Resolved PHPUnit security advisory blocking issue via
composer.jsonaudit ignore config
Full Changelog: v2.3.0...v2.3.1
v2.3.0
What's Changed
Refactoring
- Added
declare(strict_types=1)to all source files - Replaced
__call()magic delegation inGhostscript.phpwith explicit typed proxy methods for better IDE support and type safety - Replaced string-concatenation class resolution in
HandlerFactorywith an explicit handler map - Fixed nullable type hints in exception classes (
?BaseException $previous = null) - Fixed docblock typo in
ConfigTrait(@param int→@param stringfor$tmpPath)
Bug Fixes
- Fixed
SplitHandleroff-by-one bug: output files are now correctly namedpart_1.pdf–part_N.pdfto match Ghostscript's actual output - Fixed
MergeHandlerundefined variable in catch block; added guard for empty$filesarray - Fixed
GetTotalPagesHandlerundefined variable in catch block - Fixed
isPdf()inBaseHandlerto check file existence before callingmime_content_type(), preventing PHP warnings on non-existent paths - Added image type validation in
ToImageHandler(onlyjpegandpngare accepted)
Tests
- Added edge case tests across all handler test files: empty paths, non-existent files, invalid types, empty arrays, Chinese filenames
- Added
BaseHandlerTestcoveringisPdf,getTmpFile,clearTmpFiles, andvalidateBinPath - Extended
HandlerFactoryTestwith uppercase type and unknown type cases - Extended
PathHelperTestwith empty string, backslash, mixed separator, and space cases
CI / GitHub Actions
- Upgraded
actions/checkouttov5.0.1(node24 native) - Upgraded
codecov/codecov-actiontov6(resolves Node.js 20 deprecation warning) - Removed
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24workaround (no longer needed) - Coverage upload now only runs on PHP 8.4
- Added
fail-fast: falseto matrix strategy
Full Changelog: v2.2.4...v2.3.0
v2.2.4
- Fix the extension check error in the isPdf() function.
- Updated version to v2.2.4.
v2.2.3
- Add function
clearTmpFIles()to handler interface. - Updated version to v2.2.3.
v2.2.2
- Fix merge handler unable to merge does not exist path.
- Updated version to v2.2.2.
v2.2.1
- Changed image constant name.
- Updated version to v2.2.1.
v2.2.0
- 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
- Convert path separator for image & split handlers.
- Updated version to v2.1.5.
v2.1.4
- Optimize pdf to image.
- Updated version to v2.1.4.