diff --git a/Scripts/generate-qrcode.ps1 b/Scripts/generate-qrcode.ps1 index 682c4703..bdaf43b1 100755 --- a/Scripts/generate-qrcode.ps1 +++ b/Scripts/generate-qrcode.ps1 @@ -6,23 +6,23 @@ .NOTES Author: Markus Fleschutz / License: CC0 #> -param([string]$Text = "", $ImageSize = "") -if ($Text -eq "") { - $Text = read-input "Enter text or URL" -} -if ($ImageSize -eq "") { - $ImageSize = read-input "Enter image size (e.g. 500x500)" -} - -$ECC = "M" # can be L, M, Q, H -$QuietZone = 1 -$ForegroundColor = "000000" -$BackgroundColor = "ffffff" -$FileFormat = "jpg" -$PathToRepo = "$PSScriptRoot/.." -$NewFile = "$PathToRepo/Data/qrcode.jpg" +param($Text = "", $ImageSize = "") try { + if ($Text -eq "") { + $Text = read-input "Enter text or URL" + } + if ($ImageSize -eq "") { + $ImageSize = read-input "Enter image size (e.g. 500x500)" + } + $ECC = "M" # can be L, M, Q, H + $QuietZone = 1 + $ForegroundColor = "000000" + $BackgroundColor = "ffffff" + $FileFormat = "jpg" + $PathToRepo = "$PSScriptRoot/.." + $NewFile = "$PathToRepo/Data/qrcode.jpg" + $WebClient = new-object System.Net.WebClient $WebClient.DownloadFile(("http://api.qrserver.com/v1/create-qr-code/?data=" + $Text + "&ecc=" + $ECC +` "&size=" + $ImageSize + "&qzone=" + $QuietZone + `