scrapify-dev/image-tool
Composer 安装命令:
composer require scrapify-dev/image-tool
包简介
Laravel package for image tools like Compress, Resize, Rotate.
README 文档
README
📸 Scrapify Image Tools Library
A Laravel package for powerful image processing including compression, conversion, cropping, resizing, rotation, HTML-to-image conversion, upscaling, background removal (remove.bg API), and OCR (image-to-text).
This library wraps several industry-standard packages into an easy-to-use Laravel API.
📦 Installation
composer require scrapify-dev/image-tools
⚙️ Requirements
-
PHP:
^8.2 -
Laravel:
^9.0|^10.0|^11.0|^12.0 -
Dependencies:
intervention/image:^3.0barryvdh/laravel-dompdf:^3.1spatie/browsershot:^5.0spatie/pdf-to-image:^1.2thiagoalessio/tesseract_ocr:^2.13illuminate/support(as per Laravel version)
🚀 Quick Start
use Scrapify\ImageTools\CompressImage; $compressor = new CompressImage(); $result = $compressor->compress($request->file('image_file')); return response()->json([ 'filename' => $result['filename'], 'url' => $result['url'], 'size_kb' => round($result['size'] / 1024, 2), ]);
📑 Table of Contents
- Compress Image
- Convert Image
- Crop Image
- Resize Image
- Rotate Image
- HTML to Image
- Upscale Image
- Remove Background
- Image to Text (OCR)
1️⃣ Compress Image
Reduces file size with minimal quality loss. PNGs are auto-converted to JPG for better compression.
use Scrapify\ImageTools\CompressImage; $compressor = new CompressImage(); $result = $compressor->compress($request->file('image_file'));
2️⃣ Convert Image
Supported formats: jpg, png, gif, webp, avif, pdf
use Scrapify\ImageTools\ConvertImage; $converter = new ConvertImage(); $result = $converter->convert($request->file('image_file'), 'webp');
3️⃣ Crop Image
use Scrapify\ImageTools\CropImage; $cropper = new CropImage(); $result = $cropper->crop($file, [ 'x' => 100, 'y' => 50, 'width' => 200, 'height' => 150 ]);
4️⃣ Resize Image
use Scrapify\ImageTools\ResizeImage; $resizer = new ResizeImage(); $result = $resizer->resize($file, 500, 300);
5️⃣ Rotate Image
use Scrapify\ImageTools\RotateImage; $rotator = new RotateImage(); $result = $rotator->rotate($file, 90);
6️⃣ HTML to Image
Converts a live HTML page or URL to an image using ScreenshotLayer API (no Puppeteer required).
use Scrapify\ImageTools\HtmlToImage; $htmlToImage = new HtmlToImage(); $result = $htmlToImage->convert('https://example.com', 'png'); if ($result['success']) { echo "Image saved at: " . $result['url']; }
Example Class Implementation:
private $apiKey = 'YOUR_SCREENSHOTLAYER_API_KEY';
Make sure to replace with your actual API key.
7️⃣ Upscale Image
use Scrapify\ImageTools\UpscaleImage; $upscaler = new UpscaleImage(); $result = $upscaler->upscale($file, 2.0);
8️⃣ Remove Background (remove.bg API)
Removes the background of an image using the remove.bg API.
use Scrapify\ImageTools\RemoveBG; $removeBG = new RemoveBG(); $result = $removeBG->remove($request->file('image_file'));
Example Class Implementation:
$apiKey = 'YOUR_REMOVE_BG_API_KEY'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.remove.bg/v1.0/removebg"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); $postFields = [ 'image_file' => new \CURLFile( $imageFile->getRealPath(), $imageFile->getMimeType(), $imageFile->getClientOriginalName() ), 'size' => 'auto', ]; curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-Api-Key: $apiKey" ]); $result = curl_exec($ch); if (curl_errno($ch)) { throw new Exception("cURL error: " . curl_error($ch)); } curl_close($ch);
9️⃣ Image to Text (OCR)
Extracts text from an image using thiagoalessio/tesseract_ocr.
No need to install Tesseract manually — it runs directly from PHP.
use Scrapify\ImageTools\ImageToText; $imageTool = new ImageToText($file); $text = $imageTool->process();
scrapify-dev/image-tool 适用场景与选型建议
scrapify-dev/image-tool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 scrapify-dev/image-tool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 scrapify-dev/image-tool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-08-06