Skip to content

Instantly share code, notes, and snippets.

@Infinitusvoid
Last active January 3, 2024 18:16
Show Gist options
  • Save Infinitusvoid/0a0fd13583508b3a411f24bfeb572a63 to your computer and use it in GitHub Desktop.
Save Infinitusvoid/0a0fd13583508b3a411f24bfeb572a63 to your computer and use it in GitHub Desktop.
Batch with Magick : How to converet webp animated image into image frames
@echo off
setlocal enabledelayedexpansion
REM Check if magick command is available
where magick >nul 2>nul
if %errorlevel% neq 0 (
echo Error: ImageMagick not found. Please install it or make sure it's in your PATH.
exit /b 1
)
REM Check if input file is provided
if "%1"=="" (
echo Usage: %0 input.webp
exit /b 1
)
set "input_file=%1"
REM Check if the input file exists
if not exist "%input_file%" (
echo Error: File '%input_file%' not found.
exit /b 1
)
REM Create output directory
set "output_dir=output_images"
mkdir "%output_dir%" 2>nul
REM Convert and coalesce frames
magick "%input_file%" -coalesce "%output_dir%\frame_%%03d.png"
REM Reconstruct full images using montage
magick montage -geometry +0+0 "%output_dir%\frame_*.png" -tile 1x "%output_dir%\reconstructed.png"
echo Full images extracted successfully. Check the '%output_dir%' directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment