From 7feb493c1cb62122a0669629d0478694ef893c69 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 16 Aug 2012 21:23:29 +0200 Subject: [PATCH 1/1] read filenames from cli --- surrogator.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/surrogator.php b/surrogator.php index 07556bb..460cfaa 100755 --- a/surrogator.php +++ b/surrogator.php @@ -95,11 +95,18 @@ foreach ($sizes as $size) { } } -$dir = new \RegexIterator( - new \DirectoryIterator($rawDir), - '#^.+\.(png|jpg)$#' -); -foreach ($dir as $fileInfo) { +if (count($files)) { + $fileInfos = array(); + foreach ($files as $file) { + $fileInfos[] = new \SplFileInfo($file); + } +} else { + $fileInfos = new \RegexIterator( + new \DirectoryIterator($rawDir), + '#^.+\.(png|jpg)$#' + ); +} +foreach ($fileInfos as $fileInfo) { $origPath = $fileInfo->getPathname(); $fileName = $fileInfo->getFilename(); $ext = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); @@ -127,6 +134,7 @@ foreach ($dir as $fileInfo) { log(' sha256: ' . $sha256, 3); $imgSquare = imagecreatefrompng($squarePath); foreach ($sizes as $size) { + log(' size ' . $size, 3); $sizePathMd5 = $varDir . '/' . $size . '/' . $md5 . '.png'; $sizePathSha256 = $varDir . '/' . $size . '/' . $sha256 . '.png'; -- 2.30.2