treinetic/imageartist
最新稳定版本:v2.1.0
Composer 安装命令:
composer require treinetic/imageartist
包简介
ImageArtist is a php gd Wrapper which makes Image manipulation insanely easy, we introduce ImageArtist as Photoshop for php
关键字:
README 文档
README
Try out before you actually use it
docker run --pull always -p 9090:80 treineticprojects/demo_opensource:latest
ImageArtist 2.0.0
ImageArtist is a modern PHP library for easy image manipulation using the GD extension. Think of it as a fluent, cleaner API for GD. It simplifies complex tasks like shapes, text overlays, and merging.
This project is an initiative of Treinetic (Pvt) Ltd, Sri Lanka.
Features
| Feature | Description |
|---|---|
| Fluent API | Chained methods for intuitive image manipulation (scale()->crop()->save()). |
| Shapes | Built-in support for Triangles, Polygons, Circles, and Squares. |
| Text Overlays | Add multi-line text with custom fonts, colors, and positioning. |
| Layer System | New: Non-destructive editing with stacks, opacity control, and visibility toggles. |
| Filters & Effects | New: Apply standard filters (Grayscale, Blur, Brightness) fluently. |
| Smart Merging | Merge multiple images, shapes, or overlays with alpha blending support. |
| Geometric Helpers | Easy coordinate and size calculations. |
| Zero Dependencies | Lightweight, relying primarily on the standard GD extension. |
Requirements
- PHP 8.2 or higher
ext-gdextension
Optional:
ext-imagick(Required for advanced features in future versions)
Installation
1. System Dependencies
This library requires the GD Extension enabled in your environment.
Docker (Dockerfile)
RUN docker-php-ext-install gd
Ubuntu / Debian
sudo apt-get install php-gd
Alpine Linux
apk add php-gd
2. Composer
Install the package via composer:
composer require treinetic/imageartist
Usage
Basic Usage
First, import the necessary classes. Note: The namespace has been streamlined to Treinetic\ImageArtist.
use Treinetic\ImageArtist\Image; // Load an image $image = new Image("./morning.jpeg"); // Scale to 40% $image->scale(40); // Resize to specific dimensions $image->resize(1024, 768); // Save or Output $image->save("./newImage.jpg", IMAGETYPE_PNG);
Shape & Attributes
Tip
New: Detailed documentation and examples for all shapes are available in only docs/shapes.md.
use Treinetic\ImageArtist\Image; use Treinetic\ImageArtist\Shapes\Triangle; use Treinetic\ImageArtist\Commons\Node; // Create a Triangle from an image $triangle = new Triangle("./city.jpg"); // ... rest of the example
$triangle->scale(60); // Set points (Percentage or Pixels) $triangle->setPointA(20, 20, true); $triangle->setPointB(80, 20, true); $triangle->setPointC(50, 80, true); $triangle->build(); $triangle->save("./triangle.png", IMAGETYPE_PNG);
Advanced Merging & Overlays
Tip
New: Detailed documentation for Text and Overlays is available in docs/text.md.
use Treinetic\ImageArtist\Image; use Treinetic\ImageArtist\Overlays\Overlay; use Treinetic\ImageArtist\Shapes\CircularShape; use Treinetic\ImageArtist\Text\TextBox; use Treinetic\ImageArtist\Text\Color; use Treinetic\ImageArtist\Text\Font; $img = new Image("./background.jpg"); // ... rest of the example
// Add an overlay $overlay = new Overlay($img->getWidth(), $img->getHeight(), new Color(0, 0, 0, 80)); $img->merge($overlay, 0, 0); // Add a circular profile picture $circle = new CircularShape("./person.jpg"); $circle->build(); $img->merge($circle, ($img->getWidth() - $circle->getWidth()) / 2, ($img->getHeight() - $circle->getHeight()) / 2); // Add Text $textBox = new TextBox(310, 40); $textBox->setColor(new Color(255, 255, 255)); // White $textBox->setFont(Font::getFont(Font::$NOTOSERIF_REGULAR)); $textBox->setSize(20); $textBox->setText("We Are Team Treinetic"); $img->setTextBox($textBox, ($img->getWidth() - $textBox->getWidth()) / 2, $img->getHeight() * (5/7)); // Output directly to browser (ImageArtist 1.0 style) $img->dump(); // For modern usage, see new features: // - [Layers System](docs/layers.md) // - [Filters & Effects](docs/filters.md)
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 72.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 88
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-10


