Last active
April 21, 2023 10:47
-
-
Save insertish/e52d7b154ec8ed90e3ac48006d3a8956 to your computer and use it in GitHub Desktop.
Convert PDF into a GIF; https://github.com/insertish/dotfiles/blob/main/.config/fish/functions/convert-pdf-to-gif.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/fish | |
# convert the PDF into a sequence of images | |
# pick input filename | |
set PDF_NAME abc.pdf | |
# you may need to experiment with density to find the correct resolution | |
set DENSITY 300 | |
convert -density $DENSITY -quality 100 $PDF_NAME seq.png | |
# convert the sequence of images into a GIF | |
# rate is in hz (i.e. 0.5/s = 1 every 2s) | |
set RATE 0.5 | |
# pick the start slide (minus 1) | |
set START_SLIDE 8 | |
# number of slides to include | |
set NUM_SLIDES 13 | |
ffmpeg -f image2 -start_number $START_SLIDE -r $RATE -lavfi palettegen=stats_mode=single[pal],[0:v][pal]paletteuse=new=1 -i seq-%d.png -frames:v $NUM_SLIDES out.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# convert the PDF into a sequence of images | |
# pick input filename | |
PDF_NAME=abc.pdf | |
# you may need to experiment with density to find the correct resolution | |
DENSITY=300 | |
convert -density $DENSITY -quality 100 $PDF_NAME seq.png | |
# convert the sequence of images into a GIF | |
# rate is in hz (i.e. 0.5/s = 1 every 2s) | |
RATE=0.5 | |
# pick the start slide (minus 1) | |
START_SLIDE=8 | |
# number of slides to include | |
NUM_SLIDES=13 | |
ffmpeg -f image2 -start_number $START_SLIDE -r $RATE -lavfi palettegen=stats_mode=single[pal],[0:v][pal]paletteuse=new=1 -i seq-%d.png -frames:v $NUM_SLIDES out.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment