NikitchenkoSergey / idg

Licence: MIT license
Document image generator

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to idg

wp-intervention
On-demand image manipulation for WordPress via the Intervention Library.
Stars: ✭ 21 (-47.5%)
Mutual labels:  imagick, image-manipulation
lorem.space
✨✨✨🪐✨✨✨  LOREM.SPACE ✨✨✨🪐✨✨✨
Stars: ✭ 310 (+675%)
Mutual labels:  placeholder-image, image-generator
Pel
PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.
Stars: ✭ 232 (+480%)
Mutual labels:  image-manipulation
libpillowfight
Small library containing various image processing algorithms (+ Python 3 bindings) that has almost no dependencies -- Moved to Gnome's Gitlab
Stars: ✭ 60 (+50%)
Mutual labels:  image-manipulation
Image
PHP Image Manipulation
Stars: ✭ 12,298 (+30645%)
Mutual labels:  imagick
image-generator
Package for PHP 8.x to generate placeholder images with a specific size, color, text on it. You can also customize the font. (Legacy version available for PHP 7.x.)
Stars: ✭ 16 (-60%)
Mutual labels:  placeholder-image
CoCosNet-v2
CoCosNet v2: Full-Resolution Correspondence Learning for Image Translation
Stars: ✭ 312 (+680%)
Mutual labels:  image-manipulation
Pytorch Cyclegan And Pix2pix
Image-to-Image Translation in PyTorch
Stars: ✭ 16,477 (+41092.5%)
Mutual labels:  image-manipulation
markerjs2
Add image annotation to your web apps.
Stars: ✭ 107 (+167.5%)
Mutual labels:  image-manipulation
VQGAN-CLIP
Just playing with getting VQGAN+CLIP running locally, rather than having to use colab.
Stars: ✭ 2,369 (+5822.5%)
Mutual labels:  text-to-image
homebrew-extensions
🍻 Homebrew tap for PHP extensions
Stars: ✭ 264 (+560%)
Mutual labels:  imagick
js-image-carver
🌅 Content-aware image resizer and object remover based on Seam Carving algorithm
Stars: ✭ 1,467 (+3567.5%)
Mutual labels:  image-manipulation
yii2-imagick
Class for working with Imagick
Stars: ✭ 17 (-57.5%)
Mutual labels:  imagick
Finegan
FineGAN: Unsupervised Hierarchical Disentanglement for Fine-grained Object Generation and Discovery
Stars: ✭ 240 (+500%)
Mutual labels:  image-manipulation
universum-contracts
text-to-image generation gems / libraries incl. moonbirds, cyberpunks, coolcats, shiba inu doge, nouns & more
Stars: ✭ 17 (-57.5%)
Mutual labels:  text-to-image
Graphite
Open source 2D node-based raster/vector graphics editor (Photoshop + Illustrator + Houdini = Graphite)
Stars: ✭ 223 (+457.5%)
Mutual labels:  image-manipulation
holder rails
Client side image placeholders for Rails applications
Stars: ✭ 47 (+17.5%)
Mutual labels:  placeholder-image
ru-dalle
Generate images from texts. In Russian
Stars: ✭ 1,606 (+3915%)
Mutual labels:  text-to-image
Awesome-low-level-vision-resources
A curated list of resources for Low-level Vision Tasks
Stars: ✭ 35 (-12.5%)
Mutual labels:  image-manipulation
HFGI
CVPR 2022 HFGI: High-Fidelity GAN Inversion for Image Attribute Editing
Stars: ✭ 384 (+860%)
Mutual labels:  image-manipulation

Document image generator

Minimum PHP Version Build Status

Fast and simple document image generator. This is a wrapper over Imagick with which you can create such images:

Example

See: examples/index.php

Features

  • Any elements count and structure
  • padding, margin, border, background and rotation support
  • Possibility to create custom elements
  • Computed properties
  • Simple markup (like html)
  • Possibility to custom canvas by Imagick methods
  • Faster and more optimal that html->pdf->image

Requirements

PHP 5.6+, Imagick extension.

Installation

composer require idg/idg

Usage

<?php

require_once __DIR__ . '/vendor/autoload.php';
// font for example
$fontRegular = 'RobotoCondensed-Regular.ttf';

$idg = new \Idg\Idg(1000, 3000, null, new ImagickPixel('#fff'));
$idg->beginDocument(40, 30, 40, 30);
 $idg->beginRow();
        $idg->beginColumn(300);
            $idg->image('test_image.jpg');
            $idg->beginBlock()->setLeft(20);
                $idg->text('Figure 1. Dolore eu fugiat nulla pariatur.')
                ->setFont($fontRegular)->setFontSize(14)->setTextColor('#555');
            $idg->endBlock();
        $idg->endColumn();
        $idg->beginColumn(600);
                $idg->text('Lorem ipsum dolor sit amet, 
                consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 
                velit esse cillum dolore eu fugiat nulla pariatur. 
                Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.')
                    ->setFont($fontRegular);
        $idg->endColumn();
 $idg->endRow();
$idg->endDocument();
$idg->compose();

header('Content-Type: image/' . $idg->getCanvas()->getImageFormat());
print $idg->getImageBlob();

Result

Example

see: examples/columns.php

Methods

Idg

Method Return Description
Idg($width, $maxHeight, $minHeight = null, $background = null, $type = 'png') Idg Creating new generator
$idg->beginDocument($marginTop = 0, $marginLeft = 0, $marginBottom = 0, $marginRight = 0) Document Begin Document. It required.
$idg->endDocument() End document.
$idg->beginBlock() Block Begin relative block.
$idg->endBlock() End block.
$idg->beginAbsoluteBlock($top, $left) AbsoluteBlock Begin absolute block.
$idg->endAbsoluteBlock() End absolute block.
$idg->beginRow() Row Begin row.
$idg->endRow() End row.
$idg->beginColumn($width) Column Begin column.
$idg->endColumn() End column.
$idg->image($file, $fromBlob = false) Image Adding image.
$idg->text($content) Text Adding text.
$idg->addElement(Element $element) Element Add custom element.
$idg->getCanvas() Imagick Return Imagick object.
$idg->compose() Composing blocks.
$idg->getImageBlob() string Returning image result blob.
$idg->beginElement(Element $element) Element Begin custom element.
$idg->endElement() End custom element.

Element

The element is responsible for its display

Main methods

Method Return Description
Element() Element Creating new element
$element->setTop($value) Element Setting top
$element->setLeft($value) Element Setting left
$element->setWidth($value) Element Setting width
$element->setStaticHeight($value) Element Setting static height
$element->setAfterRender($closure) Element Setting after render function, see: examples/custom_element.php
$element->getParent() Element or null Get parent element
$element->getIdg() Igd Get Igd object
$element->getWidth() int Get width or parents width
$element->getLeft() int Get left
$element->getTop() int Get top
$element->getTopOffset() int Get global top offset
$element->getHeight() int Get height with children
$element->getOuterHeight() int Get height with top
$element->increaseHeight($value) Increase self height
$element->getChildren() Element[] List of children
$element->getSiblings() Element[] List of siblings with current element
$element->getPrevSibling() Element Prev sibling
$element->getPrevSiblings() Element[] List of prev siblings
$element->beforeRender() Method will call before render document
$element->render() Method will call on render document
$element->afterRender() Method will call after render document

Element properties

Padding

Method Return Description
$element->setPaddingTop($value) Element Setting padding top
$element->setPaddingLeft($value) Element Setting padding left
$element->setPaddingRight($value) Element Setting padding right
$element->setPaddingBottom($value) Element Setting padding bottom
$element->setPadding($top, $right, $bottom, $left) Element Setting padding

Margin

Method Return Description
$element->setMarginTop($value) Element Setting margin top
$element->setMarginLeft($value) Element Setting margin left
$element->setMarginRight($value) Element Setting margin right
$element->setMarginBottom($value) Element Setting margin bottom
$element->setMargin($top, $right, $bottom, $left) Element Setting margin

Border

Method Return Description
$element->setBorderColor($value) Element Setting border color
$element->setBorderWidth($value) Element Setting border width
$element->setBorder($width, $color) Element Setting border
$element->setBorderOpacity($value) Element Setting border opacity

Background

Method Return Description
$element->setBackgroundColor($value) Element Setting background color. $value can be Gradient object
$element->setBackgroundOpacity($value) Element Setting background opacity
$element->setBackground($color, $opacity) Element Setting background

Rotation

Rotation is inherit.

Method Return Description
$element->setRotation($value) Element Setting rotation
$element->getRotation() int Get rotation total rotation

Text (extends Element)

Method Return Description
$element->setAlign($value) Element Setting align
$element->setAngle($value) Element Setting angle of line
$element->setFontSize($value) Element Setting font size, 16 default
$element->setFont($value) Element Setting font family
$element->setTextColor($value) Element Setting text color, black default
$element->setDecoration($value) Element Setting text decoration
$element->setFontStyle(\ImagickDraw $draw) Element Setting style, it override all attributes

Padding, margin, border and gradient on background

Example

See: examples/properties.php

Computed properties

// .....
$idg->beginBlock();
    $idg->text('Text in block.')
            ->setMargin(10, 20, 20, 20);
$idg->endBlock();
$idg->beginBlock()->setStaticHeight(function(\Idg\Elements\Element $element) {
            return $element->getPrevSibling()->getHeight();
        });
        $idg->text('Block with height like prev.')
            ->setMargin(10, 20, 20, 20);
$idg->endBlock();
// .....

Example

See: examples/computed_properties.php

Custom elements

Example

See: examples/custom_element.php
Custom element must be instance from Element (or children)
/**
 * Custom element with green background
 * Class GreenBlock
 */
class GreenBlock extends \Idg\Elements\Element
{
    /**
     * @inheritdoc
     */
    function afterRender()
    {
        $draw = new \ImagickDraw();
        $strokeColor = new \ImagickPixel('green');
        $fillColor = new \ImagickPixel('green');

        $draw->setStrokeColor($strokeColor);
        $draw->setFillColor($fillColor);
        $draw->setFillOpacity(0.1);
        $draw->setStrokeOpacity(1);
        $draw->setStrokeWidth(2);

        $draw->rectangle($this->getLeftOffset(), $this->getTopOffset(), $this->getLeftOffset() + $this->getWidth(), $this->getTopOffset() + $this->getHeight());
        $this->getIdg()->getCanvas()->drawImage($draw);
    }
}
$customBlock = new GreenBlock();
// .....
$idg->beginElement($customBlock)->setTop(20)->setPaddingBottom(25);
// .....
$idg->endElement();
// .....

For more customization you can use standart Imagick methods:

$idg->compose();
$idg->getCanvas()->gaussianBlurImage(10, 20);

Donation

PayPal: [email protected]

Yandex.Money: 410011704835851

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].