checkParams ($options, self::PARAMS)) $this->usage (); $srcDir = $options['srcDir']; $dstDir = $options['dstDir']; $maxHeight = $options['maxHeight']; $maxWidth = $options['maxWidth']; $rewrite = isset ($options['rewrite']); $crop = isset ($options['crop']); $symbolic = isset ($options['symbolic']); set_time_limit (0); $count = 0; $dir = opendir ($srcDir); if ($dir) while ($fileName = readdir ($dir)) if (!in_array ($fileName, ['.', '..'])) { $srcFile = "$srcDir/$fileName"; $dstFile = "$dstDir/". substr ($fileName, 0, -4).'.png'; if (!file_exists ($dstFile) || $rewrite) try { $symbolicSrc = ($symbolic) ? $srcFile : NULL; $image = Image::create ($srcFile); Image::resizeSave ($image, $dstFile, $maxHeight, $maxWidth, $crop, $symbolicSrc); imagedestroy ($image); $count++; } catch (\Exception $e) {} } echo "$count files resized.\n"; } }