########################################################### # Erzeugung der HTML-Seiten für die JPG-Dateien ########################################################### [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null Add-Type -AssemblyName System.Windows.Forms . .\MyHTML.ps1 $OnlyHTML = $false $InputPath = $env:Work + '\Input' $HtmlPath = $env:Work + '\HTML' $LowResPath = $env:Work + '\LowRes' $LowResSize = 900 $LowLowResSize = 200 if (-not (Test-Path -Path $HtmlPath)) { New-Item -Path "$env:Work" -force -Name 'HTML' -ItemType 'directory' | Out-Null } if (-not (Test-Path -Path $LowResPath)) { New-Item -Path "$env:Work" -force -Name 'LowRes' -ItemType 'directory' | Out-Null } $Shell = New-Object -ComObject Shell.Application $InputFolder = $Shell.namespace($InputPath) $InputItems = $InputFolder.Items() foreach ($Item in $InputItems) { #Only process files (not folders) with suitable extension if (-not ((Test-Path -PathType Leaf $Item.Path) -and ($Item.Path -match '\.jpg$|\.jpeg$'))) { Write-Host "Skipping: $($Item.Path)" continue } Write-Host "Processing: $($Item.Path)" $OldImage = New-Object -TypeName System.Drawing.Bitmap -ArgumentList $Item.Path $OldHeight = $OldImage.Height $OldWidth = $OldImage.Width if (($OldWidth -le $LowResSize) -and ($OldHeight -le $LowResSize)) { $Height = $OldHeight $Width = $OldWidth } else { if ($OldHeight -le $OldWidth) { $Width = $LowResSize $Height = $OldHeight / $OldWidth * $Width } else { $Height = $LowResSize $Width = $OldWidth / $OldHeight * $Height } } $PSObject = New-Object PSObject #Get all the file detail items of the current file and add them to an object. # 0 - Dateiname, 1 - Dateigröße, 2 - Dateityp, 18 - Stichworte, # 20 - Autoren (wird hier für 'Siehe auch' missbraucht) # 21 - Titel, 22 - Betreff, 24 - Kommentar, 31 - Auflösung $PropIds = '0', '1', '2', '18', '20', '21', '22', '24', '31' foreach ($Id in $PropIds) { $PSObject | Add-Member -MemberType NoteProperty -Name $Id -Value ($InputFolder.getDetailsOf($Item, $Id)) } $Leaf = Split-Path -path $Item.Path -leaf $HtmlFile = ($HtmlPath + '\' + ($Leaf -split '.', 0, 'simplematch')[-2] + '.html') Write-MyPic -PSObject $PSObject -Proportion ("{0:n0}" -f ($Width / $LowResSize * 100)) | Out-File $HtmlFile -Encoding utf8 if ($OnlyHTML) { continue } $NewImage = New-Object -TypeName System.Drawing.Bitmap -ArgumentList $OldImage, $Width, $Height $Leaf = Split-Path -path $Item.Path -leaf $NewImage.Save($LowResPath + '/LR_' + $Leaf) if ($Height -gt $Width) { [int32]$Par = $Width / $Height * $LowLowResSize $NewImage = New-Object -TypeName System.Drawing.Bitmap -ArgumentList $OldImage, $Par, $LowLowRessize } else { [int32]$Par = $Height / $Width * $LowLowResSize $NewImage = New-Object -TypeName System.Drawing.Bitmap -ArgumentList $OldImage, $LowLowRessize , $Par } $NewImage.Save($LowResPath + '/LLR_' + $Leaf) } Pause