X-Git-Url: https://git.cweiske.de/surrogator.git/blobdiff_plain/fc412baac7378a01d9c5ab90405365b56d3abe4b..refs/heads/master:/surrogator.php diff --git a/surrogator.php b/surrogator.php index fdbd384..b397042 100755 --- a/surrogator.php +++ b/surrogator.php @@ -136,7 +136,7 @@ if (count($files)) { } else { $fileInfos = new \RegexIterator( new \DirectoryIterator($rawDir), - '#^.+\.(png|jpg)$#' + '#^.+\.(png|jpg|svg|svgz)$#' ); } foreach ($fileInfos as $fileInfo) { @@ -202,6 +202,9 @@ foreach ($fileInfos as $fileInfo) { */ function getHashes($fileName) { + //OpenIDs have their slashes "/" url-encoded + $fileName = rawurldecode($fileName); + $fileNameNoExt = substr($fileName, 0, -strlen(strrpos($fileName, '.')) - 2); $emailAddress = trim(strtolower($fileNameNoExt)); @@ -227,8 +230,15 @@ function createSquare($origPath, $ext, $targetPath, $maxSize) $imgOrig = imagecreatefrompng($origPath); } else if ($ext == 'jpg' || $ext == 'jpeg') { $imgOrig = imagecreatefromjpeg($origPath); + } else if ($ext == 'svg' || $ext == 'svgz') { + $imagickImg = new \Imagick(); + $imagickImg->setBackgroundColor(new \ImagickPixel('transparent')); + $imagickImg->readImage($origPath); + $imagickImg->setImageFormat('png32'); + $imgOrig = imagecreatefromstring($imagickImg->getImageBlob()); } else { //unsupported format + logErr('Unsupported image format: ' . $origPath); return false; }