org_heigl/ghostscript
Composer 安装命令:
composer require org_heigl/ghostscript
包简介
A PHP-Wrapper around the Ghostscript-CLI
README 文档
README
A PHP-wrapper to the Ghostscript-CLI
The main reason to create this library was to create images from PDF- or Postscript-files. As those Files can be either in RGB- or in CMYK-Colorspace the library tries to handle colors so that the original file and the image are close in color-impression. This is especially important as f.e. PNG is RGB-only while JPEG can be either in RGB or CMYK.
Multipaged PDF-Files will create multiple images! To not overwrite your image-files the filename will be passed to sprintf to create a filename containing the number of the page. The one and only parameter will be the number of the page.
Why another Ghostscript-Wrapper?
There are currently 2 other wrappers around that both didn't meet the requirements I had:
While the gravitymedia library concentrates more on creating PDFs from input-media the alchemy library is not easily extendable and doesn't handle the parameters to finetune Ghostscript the way I needed them.
So this library tries to handle most of the important switches to ghostscript and
also allows you to extend the library by implementing your own driver using the
DriverInterface. More information on that will be shown in the
Documentation
Installation
This package is best installed using composer.
composer require org_heigl/ghostscript
Documentation
You can find the documentation for the library at https://heiglandreas.github.io/Org_Heigl_Ghostscript
Usage
<?php
use Org_Heigl\Ghostscript\Ghostscript;
// Create the Ghostscript-Wrapper
$gs = new Ghostscript ();
// Set the output-device
$gs->setDevice('jpeg')
// Set the input file
->setInputFile('path/to/my/ps/or/pdf/file')
// Set the output file that will be created in the same directory as the input
->setOutputFile('output')
// Set the resolution to 96 pixel per inch
->setResolution(96)
// Set Text-antialiasing to the highest level
->setTextAntiAliasing(Ghostscript::ANTIALIASING_HIGH);
// Set the jpeg-quality to 100 (This is device-dependent!)
->getDevice()->setQuality(100);
// convert the input file to an image
if (true === $gs->render()) {
echo 'success';
} else {
echo 'some error occured';
}
org_heigl/ghostscript 适用场景与选型建议
org_heigl/ghostscript 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.9M 次下载、GitHub Stars 达 40, 最近一次更新时间为 2016 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 org_heigl/ghostscript 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 org_heigl/ghostscript 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.9M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 40
- 点击次数: 15
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-25