ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MakeGreyScale.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30
36{
38
39 public const ID = 'greyscale';
40
41 public function getId(): string
42 {
43 return self::ID;
44 }
45
46 public function canHandleDefinition(FlavourDefinition $definition): bool
47 {
48 return $definition instanceof ToGreyScale;
49 }
50
51 public function dependsOnEngine(): ?string
52 {
53 return GDEngine::class;
54 }
55
56 public function processStream(
57 FileInformation $information,
58 FileStream $stream,
59 FlavourDefinition $for_definition
60 ): \Generator {
62 $image = $this->from($stream);
63 if (!is_resource($image) && !$image instanceof \GdImage) {
64 return;
65 }
66 imagefilter($image, IMG_FILTER_GRAYSCALE, 50, true);
67
68 yield new Result(
69 $for_definition,
70 $this->to($image, $for_definition->getQuality()),
71 0,
72 $for_definition->persist()
73 );
74 }
75}
dependsOnEngine()
Return the class name of the Engine that is required for this Machine to work.
canHandleDefinition(FlavourDefinition $definition)
Check if a corresponding configuration can be processed by this Machine.
The base interface for all filesystem streams.
Definition: FileStream.php:32
persist()
Define whether the generated flavor and the respective streams should be persisted,...
processStream(FileInformation $information, FileStream $stream, FlavourDefinition $for_definition)
to(\GdImage $image, ?int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.