PDF-Signer

SignatureImage
in package

FinalYes

A signature as an image: anything GD can read, such as a PNG drawn with a transparent background or a photo of a signature on paper.

Transparency is kept, so only the ink covers the page. GD stores alpha in 7 bits, so it is kept to within one step of 255.

Table of Contents

Properties

$image  : GdImage
$samples  : array{0: string, 1: ?string}|null

Methods

fromFile()  : self
Reads an image file.
fromString()  : self
Reads an image from its bytes.
height()  : int
The height in pixels.
trimmed()  : self
A copy cropped to the pixels that are not fully transparent, or this image when every pixel is.
width()  : int
The width in pixels.
withoutWhiteBackground()  : self
A copy with paper-white pixels made transparent, for a signature photographed or scanned on paper.
__construct()  : mixed
blank()  : GdImage
A fully transparent truecolour canvas that keeps the alpha written to it.

Properties

$samples

private array{0: string, 1: ?string}|null $samples = null

Methods

fromFile()

Reads an image file.

public static fromFile(string $path) : self
Parameters
$path : string

The image.

Tags
throws
RuntimeException

The file could not be read.

InvalidArgumentException

The file is not an image GD can read.

Return values
self

fromString()

Reads an image from its bytes.

public static fromString(string $bytes[, string $name = 'The signature' ]) : self
Parameters
$bytes : string

The image file's contents.

$name : string = 'The signature'

What to call the image in an error message.

Tags
throws
InvalidArgumentException

The bytes are not an image GD can read.

Return values
self

height()

The height in pixels.

public height() : int
Return values
int

trimmed()

A copy cropped to the pixels that are not fully transparent, or this image when every pixel is.

public trimmed() : self
Return values
self

width()

The width in pixels.

public width() : int
Return values
int

withoutWhiteBackground()

A copy with paper-white pixels made transparent, for a signature photographed or scanned on paper.

public withoutWhiteBackground([int $hard = 235 ][, int $soft = 190 ]) : self

Pixels brighter than $hard become fully transparent and pixels darker than $soft keep their alpha; those between fade, so the edges of the ink stay smooth.

Parameters
$hard : int = 235

Brightness (0–255) at and above which a pixel is paper.

$soft : int = 190

Brightness below which a pixel is ink.

Return values
self

__construct()

private __construct(GdImage $image) : mixed
Parameters
$image : GdImage

blank()

A fully transparent truecolour canvas that keeps the alpha written to it.

private blank(int $width, int $height) : GdImage
Parameters
$width : int
$height : int
Return values
GdImage
On this page

Search results