PHP code example of realitaetsverlust / imagewrapper

1. Go to this page and download the library: Download realitaetsverlust/imagewrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

realitaetsverlust / imagewrapper example snippets


use Realitaetsverlust\Wrapper\ImageTypes\Jpeg;
use Realitaetsverlust\Wrapper\ImageTypes\Png;

$image = new Png('test.png');
$image->convert(new Jpeg());
$image->output('test.jpeg');

use Realitaetsverlust\Wrapper\ImageTypes\Jpeg;
use Realitaetsverlust\Wrapper\ImageTypes\Png;

$image = new Png('test.png');
$image->convert(new Jpeg())->output('test.jpeg');

use Realitaetsverlust\Wrapper\ImageFactory;

$image = ImageFactory::create('test.png'); // Will return a Png Object
$image = ImageFactory::create('test.jpg'); // Will return a Jpeg Object
$image = ImageFactory::create('image_with_no_extension'); // Will return the correct object, whatever it is

$image->colorize(new \Realitaetsverlust\Wrapper\Color(255, 0, 0));

$image->colorize(new \Realitaetsverlust\Wrapper\Color("#FF0000")); // Hex
$image->colorize(new \Realitaetsverlust\Wrapper\Color(0, 100, 100, 0)); // CMYK

public function output(string $destination = null, ?): bool 

public function convert(ImageBase $imageType): ImageBase

$image = new Png('test.png');
$image->convert(new Jpeg());
$image->output('test.jpeg');

public function sendHeaders() : void

public function getFileType(): string

public function getImageSize(): array 

public function getMinQuality(): int 

public function getMaxQuality(): int 

public function alphaBlending(bool $blendmode): ImageBase

public function enableAntialias(bool $enabled): ImageBase

public function drawArc(int $cx, int $cy, int $width, int $height, int $start, int $end, Color $color, int $style = null): ImageBase

public function drawChar(bool $drawVertical, int $font, int $x, int $y, string $c, int $color): ImageBase

public function getColoarAt(int $x, int $y): int|false 

public function cutPartial(int $x, int $y, int $width, int $height): ImageBase

public function crop(int $x, int $y, int $width, int $height): ImageBase

public function drawDashedLine(int $srcX, int $srcY, int $destX, int $destY, Color $color): ImageBase

public function drawEllipse(int $x, int $y, int $width, int $height, Color $color, bool $fill = false): ImageBase

public function fill(int $x, int $y, Color $color): ImageBase

public function drawPolygon(array $points, int $numberOfPoints, Color $color, bool $fill = false): ImageBase

public function drawRectangle(int $topLeft, int $topRight, int $bottomLeft, int $bottomRight, Color $color, bool $fill = false)

public function invertColors(): ImageBase

public function grayscaleImage(): ImageBase

public function setBrightness(int $brightness): ImageBase

public function setContrast(int $contrast): ImageBase

public function colorize(Color $color): ImageBase

public function edgedetect(): ImageBase

public function emboss(): ImageBase

public function blur(bool $useGauss = false): ImageBase

public function sketchImage(): ImageBase

public function smooth(int $smoothness): ImageBase

public function pixelate(int $blockSize, bool $advancedPixelationMode = false): ImageBase

public function scatter(int $effectSubstractionLevel, int $effectAdditionLevel, array $onlyApplyTo = []): ImageBase

public function gammaCorrection(float $inputGamma, float $outputGamma): ImageBase

public function flip(int $mode): ImageBase

public function setInterlace(bool $interlaceMode): ImageBase

public function isTrueColor(): bool

public function allocateColor(Color $color): false|int