Main Area and Open Discussion > General Software Discussion
Run software on GPU to compress images?
(1/1)
nickodemos:
I compress PNG images with GitHub - fhanau/Efficient-Compression-Tool: Fast and effective C++ file optimizer as this is the best compressor I have found. As with any software that compresses a file, it takes time. I was wondering if there was a way to offload the compressing to the GPU to see if there is an increase in speed.
4wd:
You'd probably have to find a program that uses OpenCL.
ECT doesn't seem to cause much CPU load, typically less than %20 on my machine so you could speed things up by running concurrent tasks.
Example:
--- Code: Text ---.\timeit.exe .\ect.exe -9 .\20221224-topaz-denoise.pngProcessed 1 fileSaved 1.95MB out of 12.34MB (15.7650%) Version Number: Windows NT 6.2 (Build 9200)Exit Time: 12:32 am, Wednesday, January 11 2023Elapsed Time: 0:01:28.952Process Time: 0:01:28.937
Five concurrent processes on the same file, (five different names):
--- Code: Text ---.\timeit.exe .\ect.exe -9 .\20221224-topaz-denoise(x).pngProcessed 1 fileSaved 1.95MB out of 12.34MB (15.7650%) Version Number: Windows NT 6.2 (Build 9200)Exit Time: 12:39 am, Wednesday, January 11 2023Elapsed Time: 0:01:42.891Process Time: 0:01:42.703
Time to process increased by 14 seconds, (this was the same for all processes give or take a few ms), CPU utilization was still under 60% so still plenty left for doing other things.
So for the cost of an extra 14 seconds I got a 5 fold increase in files processed, files had the same properties of course but it should still scale similarly.
nickodemos:
The issue is that I can not script so if you are willing to help with a script to process all png files in the current directory with ECT then it would be appreciated.
4wd:
The below tested ok on my machine, there's a lot of comments which should make it easy to understand.
Basically:
* Grabs list of PNGs in directory
* Splits list into number of cmd files along with formatting for ect.exe
* Executes cmd files
NOTES:
* Edit in the full path to ect.exe - see comments
* Edit in your ect.exe options - see comments
* I only run PowerShell 7+ so that's what I tested it on
You'll see a CLI window open for each cmd file running along with output from ect.exe in each, they close as each cmd file finishes.
--- Code: PowerShell ---<#RunEct.ps1 Open a PowerShell console: path\to\RunEct.ps1 <path of PNG files> [-Threads <x>] Default number of threads is 4 Examples: .\RunEct.ps1 d:\png-imagesd:\RunEct.ps1 "f:\png images" -Threads 8 #> param( [Parameter(Mandatory=$true)][string]$Path, [int]$Threads = 4) # Full path to ect.exe$ectPath = "R:\ect.exe"# Options for ect.exe$ectOpts = "-9" # Get the system TEMP path$tempPath = [System.IO.Path]::GetTempPath() # Get all PNG files within the directory$files = (Get-ChildItem "$($Path)/*" -Include *.png) # Collect the file names into a list$fileNames = $files.Name# Get the number of files$numberOfFiles = $fileNames.Count# Set the number of cmd files to the number of required threads to run# and set number of files per list$numberOfLists = $Threads$filesPerList = [Math]::Ceiling($numberOfFiles / $numberOfLists) # Create a list to hold the cmd file names$cmdFiles = @()# Split the number of files between the number of listsfor ($i = 0; $i -lt $numberOfLists; $i++) { $startIndex = $i * $filesPerList $endIndex = $startIndex + $filesPerList - 1 $list = $fileNames[$startIndex..$endIndex]# Create a temp cmd file $filePath = [System.IO.Path]::Combine($tempPath, "ectTempFile$($i).cmd") New-Item -Path $filePath -ItemType File -Force# Add it to the cmd file list $cmdFiles += $filePath# Output that list of files to the cmd file with formatting to run ect.exe on each $list | ForEach-Object { "$($ectPath) $($ectOpts) `"$($_)`"" } | Set-Content -Path $filePath} # Change current location to input pathPush-Location $Path # Execute each cmd file$cmdFiles | ForEach-Object {# Remove the hash (#) in the line below to have all output to the PowerShell console Start-Process cmd.exe -ArgumentList "/c $($_)" #-NoNewWindow} # Jump back to original pathPop-Location
Each ECT process causes ~10% CPU load on my Ryzen 5 5600X.
Run software on GPU to compress images?
Navigation
[0] Message Index
Go to full version