SignatureImage
in package
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
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
$image read-only
private
GdImage
$image
$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
Return values
selffromString()
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
Return values
selfheight()
The height in pixels.
public
height() : int
Return values
inttrimmed()
A copy cropped to the pixels that are not fully transparent, or this image when every pixel is.
public
trimmed() : self
Return values
selfwidth()
The width in pixels.
public
width() : int
Return values
intwithoutWhiteBackground()
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