Advertisement
Saikimo

make_animated_flair

Feb 1st, 2018
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :: default values to set
  2. @ECHO off
  3. SETLOCAL ENABLEEXTENSIONS
  4. SETLOCAL EnableDelayedExpansion
  5. SET me=%~n0
  6. SET parent=%~dp0
  7. set height=
  8. set width=
  9. set heightcounter=0
  10. set counter=0
  11. set textindent=0
  12. mkdir out
  13. cd %parent%
  14. for %%v in (*.gif) do (
  15.     set filename=%%~nv
  16.     set filename=!filename: =!
  17.     (magick "%%v" -coalesce -resize x80 tmp%%05d.jpg)
  18.     (magick tmp00000.jpg -ping -format "%%h" info:) > height.txt
  19.     (magick tmp00000.jpg -ping -format "%%w" info:) > width.txt
  20.     for /f "delims=" %%x in (height.txt) do set height=%%x
  21.     for /f "delims=" %%x in (width.txt) do set width=%%x
  22.     for /f %%A in ('dir ^| find "tmp"') do set /A counter+=1
  23.     (magick tmp*.jpg -append "out\!filename!.jpg")
  24.     set /A steps=!counter!-1
  25.     set /A backgroundheight=!height!*!steps!
  26.     set /A duration=!steps!/24
  27.     set /A textindent=!width!+5
  28.     echo counter: !counter!
  29.     echo steps: !steps!
  30.     echo width: !width!
  31.     echo height: !height!
  32.     echo background-height !backgroundheight!
  33.     echo duration: !duration!
  34.  
  35.     type NUL > out\!filename!-stylesheet.css
  36.     echo .flair-!filename! {  >> out\!filename!-stylesheet.css
  37.     echo     border: 0; >> out\!filename!-stylesheet.css
  38.     echo     padding: 0; >> out\!filename!-stylesheet.css
  39.     echo     height: !height!px; >> out\!filename!-stylesheet.css
  40.     echo     min-width: !width!px; >> out\!filename!-stylesheet.css
  41.     echo     text-indent: !textindent!px; >> out\!filename!-stylesheet.css
  42.     echo     background: url(%%%%!filename!%%%%^) repeat-y; >> out\!filename!-stylesheet.css
  43.     echo     -webkit-animation: !filename! !duration!s steps(!steps!^) infinite; >> out\!filename!-stylesheet.css
  44.     echo     animation: !filename! !duration!s steps(!steps!^) infinite; >> out\!filename!-stylesheet.css
  45.     echo     display: inline-block; >> out\!filename!-stylesheet.css
  46.     echo } >> out\!filename!-stylesheet.css
  47.     echo  
  48.     echo @-webkit-keyframes !filename!{ >> out\!filename!-stylesheet.css
  49.     echo     from {background-position: 0 0;} >> out\!filename!-stylesheet.css
  50.     echo     to { background-position: 0 !backgroundheight!px;} >> out\!filename!-stylesheet.css
  51.     echo } >> out\!filename!-stylesheet.css
  52.     echo @keyframes !filename!{ >> out\!filename!-stylesheet.css
  53.     echo     from {background-position: 0 0;} >> out\!filename!-stylesheet.css
  54.     echo     to { background-position: 0 !backgroundheight!px;} >> out\!filename!-stylesheet.css
  55.     echo } >> out\!filename!-stylesheet.css
  56.  
  57.     set counter=0
  58.     del tmp*.jpg
  59. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement