PHP code example of aportela / remote-thumbnail-cache-wrapper

1. Go to this page and download the library: Download aportela/remote-thumbnail-cache-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aportela / remote-thumbnail-cache-wrapper example snippets




    er = new \Psr\Log\NullLogger("");

    // cached thumbnails will be stored on this path
    $localPath = "./data/";

    $thumbnail = new \aportela\RemoteThumbnailCacheWrapper\JPEGThumbnail($logger, $localPath);
    $thumbnail->setDimensions(250, 250);
    $thumbnail->setQuality(\aportela\RemoteThumbnailCacheWrapper\JPEGThumbnail::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");
    }



    er = new \Psr\Log\NullLogger("");

    // cached thumbnails will be stored on this path
    $localPath = "./data/";

    $thumbnail = new \aportela\RemoteThumbnailCacheWrapper\PNGThumbnail($logger, $localPath);
    $thumbnail->setDimensions(250, 250);
    $thumbnail->setQuality(\aportela\RemoteThumbnailCacheWrapper\PNGThumbnail::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");
    }