optimize() 공개 정적인 메소드

public static optimize ( $path )
$path
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $files = rscandir(PIMCORE_TEMPORARY_DIRECTORY . "/image-thumbnails/");
     $savedBytesTotal = 0;
     foreach ($files as $file) {
         if (file_exists($file)) {
             $originalFilesize = filesize($file);
             \Pimcore\Image\Optimizer::optimize($file);
             $savedBytes = $originalFilesize - filesize($file);
             $savedBytesTotal += $savedBytes;
             $this->output->writeln("Optimized image: " . $file . " saved " . formatBytes($savedBytes));
         }
     }
     $this->output->writeln("Finished!");
     $this->output->writeln("Saved " . formatBytes($savedBytesTotal) . " in total");
 }
예제 #2
0
 /**
  *
  */
 public static function processOptimizeQueue()
 {
     $ids = TmpStore::getIdsByTag("image-optimize-queue");
     // id = path of image relative to PIMCORE_TEMPORARY_DIRECTORY
     foreach ($ids as $id) {
         $file = PIMCORE_TEMPORARY_DIRECTORY . "/" . $id;
         if (file_exists($file)) {
             $originalFilesize = filesize($file);
             \Pimcore\Image\Optimizer::optimize($file);
             \Logger::debug("Optimized image: " . $file . " saved " . formatBytes($originalFilesize - filesize($file)));
         } else {
             \Logger::debug("Skip optimizing of " . $file . " because it doesn't exist anymore");
         }
         TmpStore::delete($id);
     }
 }