Skip to content

Instantly share code, notes, and snippets.

@aaryadev
Created May 12, 2016 06:07
Show Gist options
  • Save aaryadev/524f0aa3bb7bf8a80a78d79b4da49e7e to your computer and use it in GitHub Desktop.
Save aaryadev/524f0aa3bb7bf8a80a78d79b4da49e7e to your computer and use it in GitHub Desktop.
reduce image size using php and shell command, convert and php is very common in ubuntu using them compress/resize the images in folder.
<?php
$dir = new DirectoryIterator(dirname(__FILE__));
$count=0;
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
$output= shell_exec('convert -resize 50% '.$fileinfo->getFilename().' '.$count.'.jpg');
}
$count++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment