2025-03-17 22:22:01 +01:00
|
|
|
<?php
|
|
|
|
namespace Vichan\Service\Media;
|
|
|
|
|
|
|
|
use Vichan\Data\ThumbGenerationResult;
|
|
|
|
|
|
|
|
|
2025-03-18 11:26:30 +01:00
|
|
|
interface MediaHandler {
|
2025-03-18 11:51:18 +01:00
|
|
|
/**
|
|
|
|
* PHP file upload,
|
|
|
|
*/
|
|
|
|
public const FILE_KIND_UPLOADED = 0;
|
|
|
|
/**
|
|
|
|
* Temporary file that should be moved/copied elsewhere.
|
|
|
|
*/
|
|
|
|
public const FILE_KIND_TEMPORARY = 1;
|
|
|
|
/**
|
|
|
|
* Static vichan file.
|
|
|
|
*/
|
|
|
|
public const FILE_KIND_STATIC = 2;
|
|
|
|
/**
|
|
|
|
* Live file in use by vichan in some post.
|
|
|
|
*/
|
|
|
|
public const FILE_KIND_INSTALLED = 3;
|
|
|
|
|
|
|
|
|
2025-03-17 22:22:01 +01:00
|
|
|
public function supportsMime(string $mime): bool;
|
|
|
|
|
2025-03-18 11:51:18 +01:00
|
|
|
public function openHandle(string $file_path, string $file_mime, int $file_kind): mixed;
|
2025-03-18 11:31:23 +01:00
|
|
|
|
2025-03-17 22:22:01 +01:00
|
|
|
/**
|
|
|
|
* Generates a thumbnail from the given file.
|
|
|
|
*
|
|
|
|
* @param string $source_file_path
|
2025-03-18 00:40:51 +01:00
|
|
|
* @param string $source_file_mime
|
2025-03-17 22:22:01 +01:00
|
|
|
* @param string $preferred_out_file_path
|
2025-03-18 00:40:51 +01:00
|
|
|
* @param string $preferred_out_mime
|
2025-03-17 22:22:01 +01:00
|
|
|
* @param int $max_width
|
|
|
|
* @param int $max_height
|
|
|
|
* @return ThumbGenerationResult
|
|
|
|
*/
|
2025-03-18 00:40:51 +01:00
|
|
|
public function generateThumb(
|
2025-03-18 11:26:30 +01:00
|
|
|
mixed $handle,
|
2025-03-18 00:40:51 +01:00
|
|
|
string $preferred_out_file_path,
|
|
|
|
string $preferred_out_mime,
|
|
|
|
int $max_width,
|
|
|
|
int $max_height
|
|
|
|
): ThumbGenerationResult;
|
2025-03-17 22:22:01 +01:00
|
|
|
}
|