Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
filter only images in input
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Razbakov authored Feb 1, 2017
1 parent 2b03c88 commit 5f50440
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions optimize-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ function recurseImages($dir, &$initialBytes, &$bytesSaved)
if (is_dir($current_file)) {
$stack[] = $current_file;
} else {
$initialBytes += filesize($current_file);
optimizeImage($current_file);
$bytesSaved += filesize($current_file);
$images++;
switch (strtoupper(pathinfo($current_file, PATHINFO_EXTENSION))) {
case 'GIF':
case 'PNG':
case 'JPG':
case 'JPEG':
$initialBytes += filesize($current_file);
optimizeImage($current_file);
$bytesSaved += filesize($current_file);
$images++;
break;
}
}
}
}
Expand Down

0 comments on commit 5f50440

Please sign in to comment.