Re: sat24.com erneuert
Verfasst: Mi 24. Jan 2024, 19:51
Hallo zusammen,
Mit diesem kleinen Powershellscript kann das neueste IR Satbild von Europa huntergeladen werden. Das Script kann mit einem "Windows Aufgabenplanung" Job z.B. im 5 Minten takt aufgerufen werden um damit das aktuelle Bild in einen bestimmten Ordner lokal herunterzuladen, dieses loakle Bild kann dann als Hintergrundbild definiert werden. Die UTC Zeit des SAT-Bildes wird vom Script ebenfalls oben rechts eingeblendet, das ist im original Bild nicht vorhanden. Wie stabil das läuft weiss ich noch nicht. Mal kucken.
Gruss
Stefan
Powershell Script:
$rootpath="C:\Users\Administrator\Documents\temp\meteo_sat_2\"
$filepath_working=$rootpath+'last.jpg'
$info_url="https://imn-api.meteoplaza.com/v4/nowca ... -infrared/"
#$pic_url
$response = Invoke-WebRequest -Uri $info_url
$infoC=$response.Content
$infoJ=$infoC | ConvertFrom-Json
$lasturl=$infoJ.layers | Select-Object -Last 1
$lasturl
$lastAbsurl="https://imn-api.meteoplaza.com/v4/nowca ... ttype=jpeg"
$lastAbsurl
$datum = $lasturl.time.ToString()
$textToAdd=[datetime]::ParseExact($datum, 'yyyy-MM-ddTHH:mm:ssZ', $null).ToString("dd.MM.yyyy HH:mm 'UTC'")
$savedImagePath=$filepath_working
$webrequest=Invoke-WebRequest -Uri $lastAbsurl
[System.Drawing.Image]$image=$webrequest.content
$graphics = [System.Drawing.Graphics]::FromImage($image)
# Schriftart und Größe für den Text
$font = New-Object System.Drawing.Font("Arial", 20)
# Farbe des Textes
$brush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::Black)
# Berechnen Sie die Position für den Text
$textWidth = $graphics.MeasureString($textToAdd, $font).Width
#$positionX = [Math]::Max($image.Width - $textWidth - 10, 0)
$positionX=10
$point = New-Object System.Drawing.PointF($positionX, 10)
# Text zum Bild hinzufügen
$graphics.DrawString($textToAdd, $font, $brush, $point)
# Bild speichern
$image.Save($savedImagePath)
# Ressourcen freigeben
$graphics.Dispose()
$image.Dispose()
Mit diesem kleinen Powershellscript kann das neueste IR Satbild von Europa huntergeladen werden. Das Script kann mit einem "Windows Aufgabenplanung" Job z.B. im 5 Minten takt aufgerufen werden um damit das aktuelle Bild in einen bestimmten Ordner lokal herunterzuladen, dieses loakle Bild kann dann als Hintergrundbild definiert werden. Die UTC Zeit des SAT-Bildes wird vom Script ebenfalls oben rechts eingeblendet, das ist im original Bild nicht vorhanden. Wie stabil das läuft weiss ich noch nicht. Mal kucken.
Gruss
Stefan
Powershell Script:
$rootpath="C:\Users\Administrator\Documents\temp\meteo_sat_2\"
$filepath_working=$rootpath+'last.jpg'
$info_url="https://imn-api.meteoplaza.com/v4/nowca ... -infrared/"
#$pic_url
$response = Invoke-WebRequest -Uri $info_url
$infoC=$response.Content
$infoJ=$infoC | ConvertFrom-Json
$lasturl=$infoJ.layers | Select-Object -Last 1
$lasturl
$lastAbsurl="https://imn-api.meteoplaza.com/v4/nowca ... ttype=jpeg"
$lastAbsurl
$datum = $lasturl.time.ToString()
$textToAdd=[datetime]::ParseExact($datum, 'yyyy-MM-ddTHH:mm:ssZ', $null).ToString("dd.MM.yyyy HH:mm 'UTC'")
$savedImagePath=$filepath_working
$webrequest=Invoke-WebRequest -Uri $lastAbsurl
[System.Drawing.Image]$image=$webrequest.content
$graphics = [System.Drawing.Graphics]::FromImage($image)
# Schriftart und Größe für den Text
$font = New-Object System.Drawing.Font("Arial", 20)
# Farbe des Textes
$brush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::Black)
# Berechnen Sie die Position für den Text
$textWidth = $graphics.MeasureString($textToAdd, $font).Width
#$positionX = [Math]::Max($image.Width - $textWidth - 10, 0)
$positionX=10
$point = New-Object System.Drawing.PointF($positionX, 10)
# Text zum Bild hinzufügen
$graphics.DrawString($textToAdd, $font, $brush, $point)
# Bild speichern
$image.Save($savedImagePath)
# Ressourcen freigeben
$graphics.Dispose()
$image.Dispose()