ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
FirstPageToTileImageMachine Class Reference
+ Inheritance diagram for FirstPageToTileImageMachine:
+ Collaboration diagram for FirstPageToTileImageMachine:

Public Member Functions

 __construct ()
 FlavourMachines must be able to be created without further dependencies. More...
 
 getId ()
 
 canHandleDefinition (FlavourDefinition $definition)
 Check if a corresponding configuration can be processed by this Machine. More...
 
 dependsOnEngine ()
 Return the class name of the Engine that is required for this Machine to work. More...
 
 processStream (FileInformation $information, FileStream $stream, FlavourDefinition $for_definition)
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\AbstractMachine
 __construct ()
 FlavourMachines must be able to be created without further dependencies. More...
 
 withEngine (Engine $engine)
 The demanded Engine will be passed here. More...
 
 getEngine ()
 

Data Fields

const ID = "be03e07e396a61f7d9b31a712f0913fe9c6cd43b009ce69d30aa0f10bd3500bd"
 

Protected Member Functions

 cropImage (FileStream $stream, int $width)
 

Private Attributes

const FULL_QUALITY_SIZE_THRESHOLD = 100
 
ExtractPages $extract_pages
 
CropRectangle $crop
 
ilObjectTileImageFlavourDefinition $definition = null
 
FileInformation $information = null
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\AbstractMachine
Engine $engine = null
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns AutoloadingIssuesInspection

Definition at line 38 of file FirstPageToTileImageFlavourMachine.php.

Constructor & Destructor Documentation

◆ __construct()

FirstPageToTileImageMachine::__construct ( )

FlavourMachines must be able to be created without further dependencies.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 47 of file FirstPageToTileImageFlavourMachine.php.

Member Function Documentation

◆ canHandleDefinition()

FirstPageToTileImageMachine::canHandleDefinition ( FlavourDefinition  $definition)

Check if a corresponding configuration can be processed by this Machine.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 59 of file FirstPageToTileImageFlavourMachine.php.

◆ cropImage()

FirstPageToTileImageMachine::cropImage ( FileStream  $stream,
int  $width 
)
protected

Definition at line 105 of file FirstPageToTileImageFlavourMachine.php.

Referenced by processStream().

108  {
109  $quality = $width <= self::FULL_QUALITY_SIZE_THRESHOLD
110  ? 100 // we take 100% jpeg quality for small resultions
111  : $this->definition->getQuality();
112 
113 
114  return $this->crop->processStream(
115  $this->information,
116  $stream,
117  new CropToRectangle(
118  false,
119  $width,
120  $this->definition->getRatio(),
121  $quality
122  )
123  )->current()->getStream();
124  }
+ Here is the caller graph for this function:

◆ dependsOnEngine()

FirstPageToTileImageMachine::dependsOnEngine ( )

Return the class name of the Engine that is required for this Machine to work.

Returning null will result in a NullEngine passed to the Machine.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 64 of file FirstPageToTileImageFlavourMachine.php.

64  : ?string
65  {
66  return ImagickEngine::class;
67  }

◆ getId()

FirstPageToTileImageMachine::getId ( )
Returns
string max. 64 characters, MUST be unique and NOT a class-related magic-constant. E.g. you can generate a random one with $ php -r"echo hash('sha256', uniqid());" | pbcopy in your shell and paste string in your getId() implementation.

If you ever change the ID, FlavourDefinitions may no longer process anything with your machine that previously designated you as the processing machine.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 54 of file FirstPageToTileImageFlavourMachine.php.

54  : string
55  {
56  return self::ID;
57  }

◆ processStream()

FirstPageToTileImageMachine::processStream ( FileInformation  $information,
FileStream  $stream,
FlavourDefinition  $for_definition 
)
Parameters
FileInformation$informationof the original File.
FileStream$streamof the original File.
FlavourDefinition$for_definitionthe definition for which the stream should be processed.
Returns
Result[]| For each "thing" that the machine generates, a result can be returned. E.g. when extracting 5 images from a PDF, 5 results are returned (Generator).

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 69 of file FirstPageToTileImageFlavourMachine.php.

References $information, and cropImage().

73  : \Generator {
74  $this->definition = $for_definition;
75  $this->information = $information;
76 
77  $page_stream = $this->extract_pages->processStream(
78  $this->information,
79  $stream,
80  new PagesToExtract(
81  false,
82  $this->definition->getWidths()['xl'],
83  1,
84  false,
85  100
86  )
87  )->current()?->getStream();
88 
89  if ($page_stream === null) {
90  return;
91  }
92 
93  $i = 0;
94  foreach ($for_definition->getWidths() as $width) {
95  yield new Result(
96  $for_definition,
97  $this->cropImage($page_stream, $width),
98  $i,
99  true
100  );
101  $i++;
102  }
103  }
cropImage(FileStream $stream, int $width)
+ Here is the call graph for this function:

Field Documentation

◆ $crop

CropRectangle FirstPageToTileImageMachine::$crop
private

Definition at line 43 of file FirstPageToTileImageFlavourMachine.php.

◆ $definition

ilObjectTileImageFlavourDefinition FirstPageToTileImageMachine::$definition = null
private

Definition at line 44 of file FirstPageToTileImageFlavourMachine.php.

◆ $extract_pages

ExtractPages FirstPageToTileImageMachine::$extract_pages
private

Definition at line 42 of file FirstPageToTileImageFlavourMachine.php.

◆ $information

FileInformation FirstPageToTileImageMachine::$information = null
private

Definition at line 45 of file FirstPageToTileImageFlavourMachine.php.

Referenced by processStream().

◆ FULL_QUALITY_SIZE_THRESHOLD

const FirstPageToTileImageMachine::FULL_QUALITY_SIZE_THRESHOLD = 100
private

Definition at line 41 of file FirstPageToTileImageFlavourMachine.php.

◆ ID

const FirstPageToTileImageMachine::ID = "be03e07e396a61f7d9b31a712f0913fe9c6cd43b009ce69d30aa0f10bd3500bd"

The documentation for this class was generated from the following file: