承接 scrapify-dev/image-tool 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scrapify-dev/image-tool

最新稳定版本:v1.0.0

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.0
    • barryvdh/laravel-dompdf:^3.1
    • spatie/browsershot:^5.0
    • spatie/pdf-to-image:^1.2
    • thiagoalessio/tesseract_ocr:^2.13
    • illuminate/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

  1. Compress Image
  2. Convert Image
  3. Crop Image
  4. Resize Image
  5. Rotate Image
  6. HTML to Image
  7. Upscale Image
  8. Remove Background
  9. 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();

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-08-06