GithubHelp home page GithubHelp logo

resize-assets's Introduction

example:

use Sunnysideup\ResizeAssets\ResizeAssetsRunner;

if (!Director::is_cli()) {
    exit('Only works in cli');
}

echo '---' . PHP_EOL;
echo '---' . PHP_EOL;


$directory = '/container/app/public/assets/';
$maxWidth = 3000;
$maxHeight = 2000;
$maxSize = 2;
$quality = 0.77;
$largeSizeQuality = 0.67;
$dryRun = !in_array('--real-run', $_SERVER['argv']); // Pass --dry-run as an argument to perform a dry run

echo "--- DIRECTORY: " . $directory . PHP_EOL;
echo "--- MAX-WIDTH: " . $maxWidth . PHP_EOL;
echo "--- MAX-HEIGHT: " . $maxHeight . PHP_EOL;
echo "--- MAX-SIZE: " . $maxSize . PHP_EOL;
echo "--- MAX-SIZE: " . $quality . PHP_EOL;
echo "--- MAX-SIZE: " . $largeSizeQuality . PHP_EOL;
echo "--- DRY-RUN: " . ($dryRun ? 'YES' : 'NO') . PHP_EOL;
// RUN!

ResizeAssetsRunner::set_max_file_size_in_mb($maxSize);
ResizeAssetsRunner::set_default_quality(0.77);
ResizeAssetsRunner::set_large_size_default_quality(0.67);

ResizeAssetsRunner::run_dir($directory, $maxWidth, $maxHeight, $dryRun);

echo '---' . PHP_EOL;
echo '---' . PHP_EOL;
echo 'DONE '. PHP_EOL;
echo '---' . PHP_EOL;

resize-assets's People

Contributors

sunnysideup avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.