Skip to content

Instantly share code, notes, and snippets.

@luancmaia
Created February 16, 2018 17:41
Show Gist options
  • Save luancmaia/1edaa700d675f3520632fc0a3be4deba to your computer and use it in GitHub Desktop.
Save luancmaia/1edaa700d675f3520632fc0a3be4deba to your computer and use it in GitHub Desktop.
tinify cron job
<?php
//pattern examples: '*.jpg', '*_GREEN.png', 'file.jpg'
$rq = exec("find . -name 'YOUR_PATTERN_HERE'", $out, $err);
require_once("vendor/autoload.php");
$tinify_key = '';
if ( !empty($out) ){
$images = $out;
foreach($images as $image) {
Tinify\setKey($tinify_key);
Tinify\fromFile($image)->toFile($image);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment