本帖最后由 flashercs 于 2025-4-17 14:14 编辑
回复 8# duoduo200
安装 https://imagemagick.org/script/download.php#windows
矩形变圆形.bat | @echo off | | cd /d "%~dp0" | | >nul chcp 65001 | | | | magick mogrify -depth 8 -background none -colorspace sRGB -alpha set -channel A -fx "if(pow(i-(w-1)/2,2)/pow(w/2,2)+pow(j-(h-1)/2,2)/pow(h/2,2)>1&&a>0,0.005,s)" -verbose *.png | | | | @REM cmd /q /c "echo -depth 8 -background none -compose dstin & for %%A in (*.png) do echo "%%~A" -virtual-pixel none -print %%[f]\\n ( +clone -alpha transparent -strokewidth 0 -fill white -draw "ellipse %%[fx:w/2],%%[fx:h/2] %%[fx:w/2],%%[fx:h/2] 0,360" ) -composite -write "%%~A" +delete "|magick -script - | | | | pauseCOPY |
圆形变矩形.bat | | | | | | | | | | | | | $utf8 = New-Object System.Text.UTF8Encoding -ArgumentList $false | | $OutputEncoding = [Console]::OutputEncoding = [Console]::InputEncoding = $utf8 | | Get-ChildItem -Filter *.png | ForEach-Object { | | try { | | $alpha0 = (magick.exe $_.FullName -depth 8 -colorspace sRGB -alpha set -format "%[fx:a]" info:) -as [double] | | "$($_.Name) alpha0:$alpha0" | | if ($alpha0 -eq 0) { | | | | $line = (magick.exe $_.FullName -depth 8 -colorspace sRGB -format "%[c]" histogram:info:) -notmatch '#[\dA-F]{6}00' | Sort-Object -Descending | Select-Object -First 1 | | if ($line -and $line -match '#[\dA-F]+') { | | $maincolor = $Matches[0] | | "$($_.Name) maincolor:$maincolor" | | magick.exe $_.FullName -depth 8 -background $maincolor -layers flatten $_.FullName | | } | | | | } else { | | | | magick.exe $_.FullName -depth 8 -colorspace sRGB -channel A -fx "1" $_.FullName | | } | | } finally {} | | trap {} | | }COPY |
|