This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/handle_flash/main.php

40 lines
1 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
class FlashFileHandler extends DataHandlerExtension
{
protected array $SUPPORTED_MIME = [MimeType::FLASH];
2020-02-23 18:37:22 +00:00
protected function media_check_properties(MediaCheckPropertiesEvent $event): void
{
$event->image->lossless = true;
$event->image->video = true;
$event->image->image = false;
$info = getimagesize($event->image->get_image_filename());
2020-02-23 18:37:22 +00:00
if ($info) {
$event->image->width = $info[0];
$event->image->height = $info[1];
}
}
protected function create_thumb(string $hash, string $mime): bool
{
if (!Media::create_thumbnail_ffmpeg($hash)) {
copy("ext/handle_flash/thumb.jpg", warehouse_path(Image::THUMBNAIL_DIR, $hash));
}
return true;
}
protected function check_contents(string $tmpname): bool
{
$fp = fopen($tmpname, "r");
$head = fread($fp, 3);
fclose($fp);
2020-02-23 18:14:15 +00:00
return in_array($head, ["CWS", "FWS"]);
}
}