jdz/image 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jdz/image

最新稳定版本:1.0.2

Composer 安装命令:

composer require jdz/image

包简介

JDZ Image utils

README 文档

README

JDZ Image utilities for thumbnail generation, watermark protection, and HTML rendering.

Installation

composer require jdz/image

Requirements

  • PHP >= 8.2
  • Symfony Filesystem ^7.2
  • Symfony Finder ^7.2
  • Imagine ^1.3
  • GD extension

Usage

Loading and Displaying Images

use JDZ\Image\Image;

$image = new Image('/path/to/files', 'https://mywebsite.com/');
$image->load('media/photo.jpg', 'media/default.jpg');

$pic = $image->getPic('Photo description');
echo (string)$pic;
// <img src="https://mywebsite.com/media/photo.jpg" alt="Photo description" data-orientation="landscape" />

Lazy Loading with Thumbnails

use JDZ\Image\Image;

$image = new Image('/path/to/files', 'https://mywebsite.com/', 'thumbs');
$image->lazy = true;
$image->targetWidth = 800;
$image->cacheLife = 3600;
$image->load('media/photo.jpg');

$pic = $image->getPic('Photo');
echo (string)$pic;
// src points to thumbnail, data-src points to original

Creating Thumbnails

use JDZ\Image\Thumb;

$thumb = new Thumb('/path/to/files', 800, 'thumbs', 3600);
$created = $thumb->thumbImage('media/photo.jpg');

echo $thumb->thumbFile; // 'thumbs/media_photo-800.jpg'

Watermark Protection

use JDZ\Image\Copyright;

$copyright = new Copyright('/path/to/files', 'protect', 'watermark.png', 'repeat');

// Apply watermark (original backed up to protect/ folder)
$copyright->protectImage('media/photo.jpg');

// Restore original
$copyright->unprotectImage('media/photo.jpg');

Filesystem Setup

use JDZ\Image\Fs;

$fs = new Fs('/path/to/files', 'media', 'thumbs', 'protect');
$fs->check(); // Creates media/, thumbs/, protect/ folders if missing

Image Info

use JDZ\Image\Img;

$img = new Img('/path/to/files', 'media/photo.jpg');

if ($img->valid) {
    echo $img->width;       // 1600
    echo $img->height;      // 1200
    echo $img->orientation;  // 'landscape'
    echo $img->ext;          // 'jpg'
}

Testing

composer test
# or
vendor/bin/phpunit

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固