remote-thumbnail-cache-wrapper
generate & cache thumbnails of remote & local images
Requirements
mininum php version 8.x curl extension must be enabled gd extension must be enabledLimitations
At this time only JPEG & PNG formats are supported.
Install (composer) dependencies:
composer require aportela/remote-thumbnail-cache-wrapper
Code example (from remote picture):
<?php
require "vendor/autoload.php";
$logger = new PsrLogNullLogger("");
// cached thumbnails will be stored on this path
$localPath = "./data/";
$thumbnail = new aportelaRemoteThumbnailCacheWrapperJPEGThumbnail($logger, $localPath);
$thumbnail->setDimensions(250, 250);
$thumbnail->setQuality(aportelaRemoteThumbnailCacheWrapperJPEGThumbnail::DEFAULT_IMAGE_QUALITY);
if ($thumbnail->getFromRemoteURL("https://i.imgur.com/1bo3VaU.jpeg")) {
header("Content-Type: image/jpeg");
readfile($thumbnail->path);
} else {
header("HTTP/1.1 404 Not Found");
}
Code example (from local filesystem picture):
<?php
require "vendor/autoload.php";
$logger = new PsrLogNullLogger("");
// cached thumbnails will be stored on this path
$localPath = "./data/";
$thumbnail = new aportelaRemoteThumbnailCacheWrapperPNGThumbnail($logger, $localPath);
$thumbnail->setDimensions(250, 250);
$thumbnail->setQuality(aportelaRemoteThumbnailCacheWrapperPNGThumbnail::DEFAULT_IMAGE_QUALITY);
if ($thumbnail->getFromLocalFilesystem("/tmp/test.jpg")) {
header("Content-Type: image/png");
readfile($thumbnail->path);
} else {
header("HTTP/1.1 404 Not Found");
}
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。