Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunnysideup/resize-assets
Resize images in a folder
https://github.com/sunnysideup/resize-assets
Last synced: 2 months ago
JSON representation
Resize images in a folder
- Host: GitHub
- URL: https://github.com/sunnysideup/resize-assets
- Owner: sunnysideup
- Created: 2023-07-04T02:18:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-12T20:51:40.000Z (7 months ago)
- Last Synced: 2024-09-16T07:37:08.436Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
example:
```php
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 runecho "--- 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;
```