forked from leftypol/leftypol
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
namespace Vichan\Service\Media;
|
|
|
|
use Vichan\Data\ThumbGenerationResult;
|
|
|
|
|
|
interface MediaHandler {
|
|
/**
|
|
* 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;
|
|
|
|
|
|
public function supportsMime(string $mime): bool;
|
|
|
|
public function openHandle(string $file_path, string $file_mime, int $file_kind): mixed;
|
|
|
|
public function closeHandle(mixed $handle);
|
|
|
|
public function installMediaAndGenerateThumb(
|
|
mixed $handle,
|
|
string $media_preferred_out_file_dir,
|
|
string $media_preferred_out_file_name,
|
|
string $thumb_preferred_out_file_dir,
|
|
string $thumb_preferred_out_file_name,
|
|
string $thumb_preferred_out_mime,
|
|
int $thumb_max_width,
|
|
int $thumb_max_height
|
|
);
|
|
|
|
/**
|
|
* Generates a thumbnail from the given file.
|
|
*
|
|
* @param string $source_file_path
|
|
* @param string $source_file_mime
|
|
* @param string $preferred_out_file_path
|
|
* @param string $preferred_out_mime
|
|
* @param int $max_width
|
|
* @param int $max_height
|
|
* @return ThumbGenerationResult
|
|
*/
|
|
public function generateThumb(
|
|
mixed $handle,
|
|
string $preferred_out_file_dir,
|
|
string $preferred_out_file_name,
|
|
string $preferred_out_mime,
|
|
int $max_width,
|
|
int $max_height
|
|
): ThumbGenerationResult;
|
|
}
|