setasign/setapdf-image-extractor
Composer 安装命令:
composer require setasign/setapdf-image-extractor
包简介
A proof-of-concept for extracting images from PDF files with SetaPDF.
README 文档
README
This package is a proof of concept to extract images from PDFs in pure PHP with the SetaPDF-Core component and an image render module. Currently, not all kinds of images are supported. This is also very dependent on your used image renderer library. GD and Imagick are currently implemented. We recommend you to use Imagick as it's more feature complete as GD but may be a little harder to install.
Requirements
This package is developed and tested on PHP >= 7.4.
You'll need an active license of the SetaPDF-Core component.
Requirements of the SetaPDF-Core component can be found here.
Usage
This example here extracts all images from the first page of the pdf:
$document = SetaPDF_Core_Document::loadByFilename('your-pdf-file.pdf'); $images = \setasign\SetaPDF\ImageExtractor\ImageExtractor::getImagesByPageNo($document, 1); foreach ($images as $imageData) { // if you're using imagick $imagick = \setasign\SetaPDF\ImageExtractor\ImageExtractor::toImage($imageData, ImageExtractor::IMAGE_RENDERER_IMAGICK); $imagick->setImageFormat('png'); $image = $imagick->getImageBlob(); $imagick->destroy(); echo '<img src="data:image/png;base64,' . base64_encode($image) . '"/>'; // if you're using gd use this code instead $gd = ImageExtractor::toImage($imageData, ImageExtractor::IMAGE_RENDERER_GD); ob_start(); imagepng($gd); $image = ob_get_clean(); imagedestroy($gd); echo '<img src="data:image/png;base64,' . base64_encode($image) . '"/>'; }
License
This package is open-sourced software licensed under the MIT license.
setasign/setapdf-image-extractor 适用场景与选型建议
setasign/setapdf-image-extractor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 setasign/setapdf-image-extractor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 setasign/setapdf-image-extractor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-27