<# : @echo off cd /d "%~dp0" powershell -NoProfile -ExecutionPolicy Bypass -Command "iex (${%~f0} | out-string)" pause exit /b #> # PowerShell Script Starts Here Add-Type -AssemblyName System.Drawing # Settings $sourceDir = Get-Location $baseDest = "C:\Users\chozdo\Documents\esp retro photos" $timeStamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" # Folder Structure $mainFolder = Join-Path $baseDest $timeStamp $origFolder = Join-Path $mainFolder "Originals" $simpleConvFolder = Join-Path $mainFolder "Converted_Only" $upscaleFolder = Join-Path $mainFolder "Upscaled_4x" # Create Directories if (!(Test-Path $baseDest)) { New-Item -ItemType Directory -Force -Path $baseDest | Out-Null } New-Item -ItemType Directory -Force -Path $origFolder | Out-Null New-Item -ItemType Directory -Force -Path $simpleConvFolder | Out-Null New-Item -ItemType Directory -Force -Path $upscaleFolder | Out-Null Write-Host "Processing photos..." -ForegroundColor Green # Find BMP files $files = Get-ChildItem -Path $sourceDir -Filter *.bmp foreach ($file in $files) { try { # Load Original Image $img = [System.Drawing.Bitmap]::FromFile($file.FullName) $newName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) + ".jpg" # --- 1. Simple Conversion (No Resize) --- $simplePath = Join-Path $simpleConvFolder $newName $img.Save($simplePath, [System.Drawing.Imaging.ImageFormat]::Jpeg) # --- 2. Upscaling (4x Bicubic - Smoother) --- $newWidth = $img.Width * 4 $newHeight = $img.Height * 4 $newImg = New-Object System.Drawing.Bitmap($newWidth, $newHeight) $graph = [System.Drawing.Graphics]::FromImage($newImg) # შევცვალეთ მეთოდი HighQualityBicubic-ზე (უფრო რბილი და ბუნებრივი) $graph.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic $graph.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality $graph.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality $graph.DrawImage($img, 0, 0, $newWidth, $newHeight) $upscalePath = Join-Path $upscaleFolder $newName $newImg.Save($upscalePath, [System.Drawing.Imaging.ImageFormat]::Jpeg) # Cleanup Memory $graph.Dispose() $newImg.Dispose() $img.Dispose() # --- 3. Move Original --- Move-Item -Path $file.FullName -Destination $origFolder Write-Host "Done: $($file.Name)" } catch { Write-Host "Error processing: $($file.Name)" -ForegroundColor Red } } # Open the new folder automatically Invoke-Item $mainFolder Write-Host "All operations completed!" -ForegroundColor Cyan