2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-08-16 14:40:42 +00:00
|
|
|
|
|
|
|
class MediaResizeEvent extends Event
|
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public string $engine;
|
|
|
|
public string $input_path;
|
|
|
|
public string $input_mime;
|
|
|
|
public string $output_path;
|
|
|
|
public ?string $target_mime;
|
|
|
|
public int $target_width;
|
|
|
|
public int $target_height;
|
|
|
|
public int $target_quality;
|
|
|
|
public string $alpha_color;
|
|
|
|
public bool $minimize;
|
|
|
|
public bool $allow_upscale;
|
|
|
|
public string $resize_type;
|
2019-08-16 14:40:42 +00:00
|
|
|
|
2019-11-02 19:57:34 +00:00
|
|
|
public function __construct(
|
2021-03-14 23:43:50 +00:00
|
|
|
string $engine,
|
2019-11-02 19:57:34 +00:00
|
|
|
string $input_path,
|
2020-06-14 16:05:55 +00:00
|
|
|
string $input_mime,
|
2019-11-02 19:57:34 +00:00
|
|
|
string $output_path,
|
|
|
|
int $target_width,
|
|
|
|
int $target_height,
|
2020-06-11 21:58:19 +00:00
|
|
|
string $resize_type = Media::RESIZE_TYPE_FIT,
|
2020-06-14 16:05:55 +00:00
|
|
|
string $target_mime = null,
|
2020-06-14 16:36:52 +00:00
|
|
|
string $alpha_color = Media::DEFAULT_ALPHA_CONVERSION_COLOR,
|
2019-11-02 19:57:34 +00:00
|
|
|
int $target_quality = 80,
|
|
|
|
bool $minimize = false,
|
|
|
|
bool $allow_upscale = true
|
|
|
|
) {
|
2020-01-26 13:19:35 +00:00
|
|
|
parent::__construct();
|
2019-08-16 14:40:42 +00:00
|
|
|
assert(in_array($engine, MediaEngine::ALL));
|
|
|
|
$this->engine = $engine;
|
|
|
|
$this->input_path = $input_path;
|
2020-06-14 16:05:55 +00:00
|
|
|
$this->input_mime = $input_mime;
|
2019-08-16 14:40:42 +00:00
|
|
|
$this->output_path = $output_path;
|
|
|
|
$this->target_height = $target_height;
|
|
|
|
$this->target_width = $target_width;
|
2020-06-14 16:05:55 +00:00
|
|
|
$this->target_mime = $target_mime;
|
2020-06-14 16:36:52 +00:00
|
|
|
if (empty($alpha_color)) {
|
|
|
|
$alpha_color = Media::DEFAULT_ALPHA_CONVERSION_COLOR;
|
|
|
|
}
|
|
|
|
$this->alpha_color = $alpha_color;
|
2019-08-16 14:40:42 +00:00
|
|
|
$this->target_quality = $target_quality;
|
|
|
|
$this->minimize = $minimize;
|
|
|
|
$this->allow_upscale = $allow_upscale;
|
2020-06-11 21:58:19 +00:00
|
|
|
$this->resize_type = $resize_type;
|
2019-08-16 14:40:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MediaCheckPropertiesEvent extends Event
|
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public Image $image;
|
|
|
|
public string $file_name;
|
|
|
|
public string $mime;
|
2019-08-16 14:40:42 +00:00
|
|
|
|
2020-01-29 20:22:50 +00:00
|
|
|
public function __construct(Image $image)
|
2019-08-16 14:40:42 +00:00
|
|
|
{
|
2020-01-26 13:19:35 +00:00
|
|
|
parent::__construct();
|
2020-01-29 20:22:50 +00:00
|
|
|
$this->image = $image;
|
|
|
|
$this->file_name = warehouse_path(Image::IMAGE_DIR, $image->hash);
|
2020-06-14 16:05:55 +00:00
|
|
|
$this->mime = strtolower($image->get_mime());
|
2019-08-16 14:40:42 +00:00
|
|
|
}
|
|
|
|
}
|