Skip to content

Instantly share code, notes, and snippets.

@khlizard
Created January 26, 2025 07:12
Show Gist options
  • Save khlizard/d0df40bae41e26be74f1dbe345706553 to your computer and use it in GitHub Desktop.
Save khlizard/d0df40bae41e26be74f1dbe345706553 to your computer and use it in GitHub Desktop.
画像をVRCのステッカー用にするバッチファイル Imagemagick使用
@echo off
cd /d %~dp0
setlocal EnableDelayedExpansion
@REM ImageMagickのパスを環境に合わせて各自設定
set PATH=%PATH%;C:\Program Files\ImageMagick-7.1.1-Q16-HDRI
if "%~1" == "" (
echo 画像ファイルをドラッグ&ドロップしてください。
pause
exit /b 1
)
magick "%1" -resize 1024x1024^ temp94_resize.png
@REM 画像のサイズを取得
for /f "tokens=1,2" %%a in ('magick temp94_resize.png -format "%%w %%h" info:') do (
set WIDTH=%%a
set HEIGHT=%%b
)
@REM マスク画像を作成
magick -size !WIDTH!x!HEIGHT! xc:none -fill white -draw "roundRectangle 0,0 !WIDTH!,!HEIGHT! 20,20" temp94_mask.png
@REM マスクを適用して角丸に
magick temp94_resize.png -alpha Set temp94_mask.png -compose DstIn -composite temp94_rounded.png
@REM 1024x1024の透過PNGに変換
magick temp94_rounded.png -resize 1024x1024^ -background transparent -compose Copy -gravity center -extent 1024x1024 output_sticker.png
@REM 一時ファイルを削除
del "temp94_*.png"
exit /b 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment