classes-Com-Tecnick-Pdf-Image-Import

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.

Com\Tecnick\Pdf\Image\Import

Tags
since
2011-05-23
category

Library

author

Nicola Asuni info@tecnick.com

copyright

2011-2016 Nicola Asuni - Tecnick.com LTD

license

http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)

link
https://github.com/tecnickcom/tc-lib-pdf-image

Table of Contents

$cache  : array<string|int, mixed>
Cache used to store imported image data.
$colspacemap  : array<string|int, mixed>
Map number of channels with color space name
$enc  : Encrypt
Encrypt object
$iid  : int
Image index.
$image  : array<string|int, mixed>
Stack of added images.
$kunit  : float
Unit of measure conversion ratio
$lossless  : array<string|int, mixed>
Lossless image types
$pdfa  : bool
True if we are in PDF/A mode.
$pon  : int
Current PDF object number
$xobjdict  : array<string|int, mixed>
Store image object IDs for the XObject Dictionary.
$native  : array<string|int, mixed>
Native image types and associated importing class (image types for which we have an import method)
__construct()  : mixed
Initialize images data
add()  : int
Add a new image
getImageDataByKey()  : array<string|int, mixed>
Get an imported image by key
getKey()  : string
Get the Image key used for caching
getObjectNumber()  : int
Returns current PDF object number
getOutImagesBlock()  : string
Get the PDF output string for Images
getSetImage()  : string
Get the PDF output string to print the specified image ID
getXobjectDict()  : string
Return XObjects Dictionary portion for the images
getAlphaChannelRawData()  : array<string|int, mixed>
Extract the alpha channel as separate image to be used as a mask
getData()  : array<string|int, mixed>
Extract the relevant data from the image
getMetaData()  : array<string|int, mixed>
Get the image meta data
getOutAltImages()  : string
Get the PDF output string for Alternate images object
getOutColorInfo()  : string
Get the PDF output string for color and mask information
getOutIcc()  : string
Get the PDF output string for ICC object
getOutImage()  : string
Get the PDF output string for Image object
getOutPalette()  : string
Get the PDF output string for Indexed palette object
getOutTransparency()  : string
Get the PDF output string for color and mask information
getRawData()  : array<string|int, mixed>
Get the original image raw data
getResizedRawData()  : array<string|int, mixed>
Get the resized image raw data (always convert the image type to a native format: PNG or JPEG)
import()  : array<string|int, mixed>
Import the original image raw data
createImportImage()  : ImageImportInterface

Properties

$cache

Cache used to store imported image data.

protected array<string|int, mixed> $cache = array()

The same image data can be reused multiple times.

$colspacemap

Map number of channels with color space name

protected static array<string|int, mixed> $colspacemap = array(1 => 'DeviceGray', 3 => 'DeviceRGB', 4 => 'DeviceCMYK')

$enc

Encrypt object

protected Encrypt $enc

$iid

Image index.

protected int $iid = 0

Count the number of added images.

$image

Stack of added images.

protected array<string|int, mixed> $image = array()

$kunit

Unit of measure conversion ratio

protected float $kunit = 1.0

$lossless

Lossless image types

protected static array<string|int, mixed> $lossless = array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_PSD, IMAGETYPE_BMP, IMAGETYPE_WBMP, IMAGETYPE_XBM, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM, IMAGETYPE_IFF, IMAGETYPE_SWC, IMAGETYPE_ICO)

$pdfa

True if we are in PDF/A mode.

protected bool $pdfa = false

$pon

Current PDF object number

protected int $pon

$xobjdict

Store image object IDs for the XObject Dictionary.

protected array<string|int, mixed> $xobjdict = array()

$native

Native image types and associated importing class (image types for which we have an import method)

private static array<string|int, mixed> $native = array(IMAGETYPE_PNG => 'Png', IMAGETYPE_JPEG => 'Jpeg')

Methods

__construct()

Initialize images data

public __construct(float $kunit, Encrypt $enc[, bool $pdfa = false ]) : mixed
Parameters
$kunit : float

Unit of measure conversion ratio.

$enc : Encrypt

Encrypt object.

$pdfa : bool = false

True if we are in PDF/A mode.

Return values
mixed

add()

Add a new image

public add(string $image[, int $width = null ][, int $height = null ][, bool $ismask = false ][, int $quality = 100 ][, bool $defprint = false ][, array<string|int, mixed> $altimgs = array() ]) : int
Parameters
$image : string

Image file name, URL or a '@' character followed by the image data string. To link an image without embedding it on the document, set an asterisk character before the URL (i.e.: '*http://www.example.com/image.jpg').

$width : int = null

New width in pixels or null to keep the original value

$height : int = null

New height in pixels or null to keep the original value

$ismask : bool = false

True if the image is a transparency mask

$quality : int = 100

Quality for JPEG files (0 = max compression; 100 = best quality, bigger file).

$defprint : bool = false

Indicate if the image is the default for printing when used as alternative image.

$altimgs : array<string|int, mixed> = array()

Arrays of alternate image keys.

Return values
int

Image ID

getImageDataByKey()

Get an imported image by key

public getImageDataByKey(string $key) : array<string|int, mixed>
Parameters
$key : string

Image key

Return values
array<string|int, mixed>

Image raw data array

getKey()

Get the Image key used for caching

public getKey(string $image, int $width, int $height[, int $quality = 100 ]) : string
Parameters
$image : string

Image file name or content

$width : int

Width in pixels

$height : int

Height in pixels

$quality : int = 100

Quality for JPEG files

Return values
string

getObjectNumber()

Returns current PDF object number

public getObjectNumber() : int
Return values
int

getOutImagesBlock()

Get the PDF output string for Images

public getOutImagesBlock(int $pon) : string
Parameters
$pon : int

Current PDF Object Number

Return values
string

getSetImage()

Get the PDF output string to print the specified image ID

public getSetImage(int $iid, int $xpos, int $ypos, int $width, int $height, int $pageheight) : string
Parameters
$iid : int

Image ID

$xpos : int

Abscissa (X coordinate) of the upper-left Image corner

$ypos : int

Ordinate (Y coordinate) of the upper-left Image corner

$width : int

Image width in user units

$height : int

Image height in user units

$pageheight : int

Page height in user units

Return values
string

getXobjectDict()

Return XObjects Dictionary portion for the images

public getXobjectDict() : string
Return values
string

getAlphaChannelRawData()

Extract the alpha channel as separate image to be used as a mask

protected getAlphaChannelRawData(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

Image raw data as returned by getImageRawData

Return values
array<string|int, mixed>

Image raw data array

getData()

Extract the relevant data from the image

protected getData(array<string|int, mixed> $data, int $width, int $height, int $quality) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

Image raw data

$width : int

Width in pixels

$height : int

Height in pixels

$quality : int

Quality for JPEG files

Return values
array<string|int, mixed>

getMetaData()

Get the image meta data

protected getMetaData(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

Image raw data

Return values
array<string|int, mixed>

Image raw data array

getOutAltImages()

Get the PDF output string for Alternate images object

protected getOutAltImages(array<string|int, mixed> $img, array<string|int, mixed> &$data[, string $sub = '' ]) : string
Parameters
$img : array<string|int, mixed>

Image reference

$data : array<string|int, mixed>

Image raw data

$sub : string = ''

Sub image ('mask', 'plain' or empty string)

Return values
string

getOutColorInfo()

Get the PDF output string for color and mask information

protected getOutColorInfo(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

Image raw data

Return values
string

getOutIcc()

Get the PDF output string for ICC object

protected getOutIcc(array<string|int, mixed> &$data) : string
Parameters
$data : array<string|int, mixed>

Image raw data

Return values
string

getOutImage()

Get the PDF output string for Image object

protected getOutImage(array<string|int, mixed> &$img, array<string|int, mixed> &$data[, string $sub = '' ]) : string
Parameters
$img : array<string|int, mixed>

Image reference

$data : array<string|int, mixed>

Image raw data

$sub : string = ''

Sub image ('mask', 'plain' or empty string)

Return values
string

getOutPalette()

Get the PDF output string for Indexed palette object

protected getOutPalette(array<string|int, mixed> &$data) : string
Parameters
$data : array<string|int, mixed>

Image raw data

Return values
string

getOutTransparency()

Get the PDF output string for color and mask information

protected getOutTransparency(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

Image raw data

Return values
string

getRawData()

Get the original image raw data

protected getRawData(string $image) : array<string|int, mixed>
Parameters
$image : string

Image file name, URL or a '@' character followed by the image data string. To link an image without embedding it on the document, set an asterisk character before the URL (i.e.: '*http://www.example.com/image.jpg').

Return values
array<string|int, mixed>

Image data array

getResizedRawData()

Get the resized image raw data (always convert the image type to a native format: PNG or JPEG)

protected getResizedRawData(array<string|int, mixed> $data, int $width, int $height[, bool $alpha = true ][, int $quality = 100 ]) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

Image raw data as returned by getImageRawData

$width : int

New width in pixels

$height : int

New height in pixels

$alpha : bool = true

If true save the alpha channel information, if false merge the alpha channel (PNG mode)

$quality : int = 100

Quality for JPEG files (0 = max compression; 100 = best quality, bigger file).

Return values
array<string|int, mixed>

Image raw data array

import()

Import the original image raw data

protected import(string $image[, int $width = null ][, int $height = null ][, bool $ismask = false ][, int $quality = 100 ]) : array<string|int, mixed>
Parameters
$image : string

Image file name, URL or a '@' character followed by the image data string. To link an image without embedding it on the document, set an asterisk character before the URL (i.e.: '*http://www.example.com/image.jpg').

$width : int = null

New width in pixels or null to keep the original value

$height : int = null

New height in pixels or null to keep the original value

$ismask : bool = false

True if the image is a transparency mask

$quality : int = 100

Quality for JPEG files (0 = max compression; 100 = best quality, bigger file).

Return values
array<string|int, mixed>

Image raw data array

 

© 2004-2022 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy