#keyworda inkscape, svg, png, icon, powershell, cli {{{ # Inkscape 실행 파일 경로 (무설치 버전의 inkscape.exe 경로로 변경) $inkscapePath = "C:\path\to\inkscape-portable\inkscape\bin\inkscape.exe" # 입력 및 출력 폴더 경로 $inputFolder = "C:\path\to\svg\folder" $outputFolder = "C:\path\to\png\folder" # 배치 크기 설정 (CPU 부하 감소를 위해 3으로 설정) $batchSize = 3 # 파일 처리 간 지연 시간 (초, CPU 부하 감소를 위해 3초로 설정) $delaySeconds = 3 # 출력 폴더가 없으면 생성 if (-not (Test-Path $outputFolder)) { New-Item -ItemType Directory -Path $outputFolder } # SVG 파일 목록 가져오기 $svgFiles = Get-ChildItem "$inputFolder\*.svg" $totalFiles = $svgFiles.Count Write-Host "Total SVG files to process: $totalFiles" # 배치 단위로 파일 처리 $batchCount = [math]::Ceiling($totalFiles / $batchSize) for ($i = 0; $i -lt $batchCount; $i++) { $startIndex = $i * $batchSize $batchFiles = $svgFiles | Select-Object -Skip $startIndex -First $batchSize Write-Host "Processing batch $($i + 1) of $batchCount ($($batchFiles.Count) files) at $(Get-Date)" foreach ($file in $batchFiles) { $filename = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) $outputPath = Join-Path $outputFolder "$filename.png" # 이미 변환된 파일 건너뛰기 if (Test-Path $outputPath) { Write-Host "Skipped: $filename.png already exists" continue } # Inkscape 프로세스 실행 (우선순위 낮춤) try { $process = Start-Process -FilePath $inkscapePath -ArgumentList "`"$($file.FullName)`" --export-filename=`"$outputPath`" -w 800 -h 600" -NoNewWindow -Wait -PassThru $process.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::BelowNormal if ($process.ExitCode -eq 0) { Write-Host "Converted: $($file.Name) -> $filename.png" } else { Write-Host "Error converting: $($file.Name) (Exit code: $($process.ExitCode))" } } catch { Write-Host "Error converting: $($file.Name) - $($_.Exception.Message)" } # Inkscape 잔류 프로세스 정리 Get-Process -Name "inkscape" -ErrorAction SilentlyContinue | Stop-Process -Force # CPU 부하 감소를 위해 지연 Start-Sleep -Seconds $delaySeconds } } Write-Host "Conversion completed at $(Get-Date)" }}}