16577bfc3SGreg Roach<?php 26577bfc3SGreg Roach 36577bfc3SGreg Roach/** 46577bfc3SGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 webtrees development team 66577bfc3SGreg Roach * This program is free software: you can redistribute it and/or modify 76577bfc3SGreg Roach * it under the terms of the GNU General Public License as published by 86577bfc3SGreg Roach * the Free Software Foundation, either version 3 of the License, or 96577bfc3SGreg Roach * (at your option) any later version. 106577bfc3SGreg Roach * This program is distributed in the hope that it will be useful, 116577bfc3SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 126577bfc3SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 136577bfc3SGreg Roach * GNU General Public License for more details. 146577bfc3SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 166577bfc3SGreg Roach */ 176577bfc3SGreg Roach 186577bfc3SGreg Roachdeclare(strict_types=1); 196577bfc3SGreg Roach 206577bfc3SGreg Roachnamespace Fisharebest\Webtrees\Contracts; 216577bfc3SGreg Roach 226577bfc3SGreg Roachuse Fisharebest\Webtrees\MediaFile; 236577bfc3SGreg Roachuse Intervention\Image\Image; 24*f7cf8a15SGreg Roachuse League\Flysystem\FilesystemOperator; 256577bfc3SGreg Roachuse Psr\Http\Message\ResponseInterface; 266577bfc3SGreg Roach 276577bfc3SGreg Roach/** 286577bfc3SGreg Roach * Make an image (from another image). 296577bfc3SGreg Roach */ 306577bfc3SGreg Roachinterface ImageFactoryInterface 316577bfc3SGreg Roach{ 326577bfc3SGreg Roach /** 336577bfc3SGreg Roach * Send the original file - either inline or as a download. 346577bfc3SGreg Roach * 35*f7cf8a15SGreg Roach * @param FilesystemOperator $filesystem 366577bfc3SGreg Roach * @param string $path 376577bfc3SGreg Roach * @param bool $download 386577bfc3SGreg Roach * 396577bfc3SGreg Roach * @return ResponseInterface 406577bfc3SGreg Roach */ 41*f7cf8a15SGreg Roach public function fileResponse(FilesystemOperator $filesystem, string $path, bool $download): ResponseInterface; 426577bfc3SGreg Roach 436577bfc3SGreg Roach /** 446577bfc3SGreg Roach * Send the original file - either inline or as a download. 456577bfc3SGreg Roach * 46*f7cf8a15SGreg Roach * @param FilesystemOperator $filesystem 476577bfc3SGreg Roach * @param string $path 486577bfc3SGreg Roach * @param int $width 496577bfc3SGreg Roach * @param int $height 506577bfc3SGreg Roach * @param string $fit 516577bfc3SGreg Roach * 526577bfc3SGreg Roach * @return ResponseInterface 536577bfc3SGreg Roach */ 546577bfc3SGreg Roach public function thumbnailResponse( 55*f7cf8a15SGreg Roach FilesystemOperator $filesystem, 566577bfc3SGreg Roach string $path, 576577bfc3SGreg Roach int $width, 586577bfc3SGreg Roach int $height, 596577bfc3SGreg Roach string $fit 606577bfc3SGreg Roach ): ResponseInterface; 616577bfc3SGreg Roach 626577bfc3SGreg Roach /** 636577bfc3SGreg Roach * Create a full-size version of an image. 646577bfc3SGreg Roach * 656577bfc3SGreg Roach * @param MediaFile $media_file 666577bfc3SGreg Roach * @param bool $add_watermark 676577bfc3SGreg Roach * @param bool $download 686577bfc3SGreg Roach * 696577bfc3SGreg Roach * @return ResponseInterface 706577bfc3SGreg Roach */ 716577bfc3SGreg Roach public function mediaFileResponse(MediaFile $media_file, bool $add_watermark, bool $download): ResponseInterface; 726577bfc3SGreg Roach 736577bfc3SGreg Roach /** 746577bfc3SGreg Roach * Create a smaller version of an image. 756577bfc3SGreg Roach * 766577bfc3SGreg Roach * @param MediaFile $media_file 776577bfc3SGreg Roach * @param int $width 786577bfc3SGreg Roach * @param int $height 796577bfc3SGreg Roach * @param string $fit 806577bfc3SGreg Roach * @param bool $add_watermark 816577bfc3SGreg Roach * 826577bfc3SGreg Roach * @return ResponseInterface 836577bfc3SGreg Roach */ 846577bfc3SGreg Roach public function mediaFileThumbnailResponse( 856577bfc3SGreg Roach MediaFile $media_file, 866577bfc3SGreg Roach int $width, 876577bfc3SGreg Roach int $height, 886577bfc3SGreg Roach string $fit, 896577bfc3SGreg Roach bool $add_watermark 906577bfc3SGreg Roach ): ResponseInterface; 916577bfc3SGreg Roach 926577bfc3SGreg Roach /** 936577bfc3SGreg Roach * Does a full-sized image need a watermark? 946577bfc3SGreg Roach * 956577bfc3SGreg Roach * @param MediaFile $media_file 966577bfc3SGreg Roach * @param UserInterface $user 976577bfc3SGreg Roach * 986577bfc3SGreg Roach * @return bool 996577bfc3SGreg Roach */ 1006577bfc3SGreg Roach public function fileNeedsWatermark(MediaFile $media_file, UserInterface $user): bool; 1016577bfc3SGreg Roach 1026577bfc3SGreg Roach /** 1036577bfc3SGreg Roach * Does a thumbnail image need a watermark? 1046577bfc3SGreg Roach * 1056577bfc3SGreg Roach * @param MediaFile $media_file 1066577bfc3SGreg Roach * @param UserInterface $user 1076577bfc3SGreg Roach * 1086577bfc3SGreg Roach * @return bool 1096577bfc3SGreg Roach */ 1106577bfc3SGreg Roach public function thumbnailNeedsWatermark(MediaFile $media_file, UserInterface $user): bool; 1116577bfc3SGreg Roach 1126577bfc3SGreg Roach /** 1136577bfc3SGreg Roach * Create a watermark image, perhaps specific to a media-file. 1146577bfc3SGreg Roach * 1156577bfc3SGreg Roach * @param int $width 1166577bfc3SGreg Roach * @param int $height 1176577bfc3SGreg Roach * @param MediaFile $media_file 1186577bfc3SGreg Roach * 1196577bfc3SGreg Roach * @return Image 1206577bfc3SGreg Roach */ 1216577bfc3SGreg Roach public function createWatermark(int $width, int $height, MediaFile $media_file): Image; 1226577bfc3SGreg Roach 1236577bfc3SGreg Roach /** 1246577bfc3SGreg Roach * Add a watermark to an image. 1256577bfc3SGreg Roach * 1266577bfc3SGreg Roach * @param Image $image 1276577bfc3SGreg Roach * @param Image $watermark 1286577bfc3SGreg Roach * 1296577bfc3SGreg Roach * @return Image 1306577bfc3SGreg Roach */ 1316577bfc3SGreg Roach public function addWatermark(Image $image, Image $watermark): Image; 1326577bfc3SGreg Roach 1336577bfc3SGreg Roach /** 1346577bfc3SGreg Roach * Send a replacement image, to replace one that could not be found or created. 1356577bfc3SGreg Roach * 1366577bfc3SGreg Roach * @param string $text HTTP status code or file extension 1376577bfc3SGreg Roach * 1386577bfc3SGreg Roach * @return ResponseInterface 1396577bfc3SGreg Roach */ 1406577bfc3SGreg Roach public function replacementImageResponse(string $text): ResponseInterface; 1416577bfc3SGreg Roach} 142