Skip to content

Instantly share code, notes, and snippets.

@ajmas
Last active November 1, 2020 22:19
Show Gist options
  • Save ajmas/0e8364446a40196100d8e465d29b63bf to your computer and use it in GitHub Desktop.
Save ajmas/0e8364446a40196100d8e465d29b63bf to your computer and use it in GitHub Desktop.
CLI File Conversion methods, with open source tools

Note, all commands represent the bare minimum need to do the conversion. Optimisations are generally not indicated, unless they are really needed. Also, you'll need to install the necessary tools, since many are are unlikely to be installed by default. This list is by no means definitive and is more something I put together as a reference for myself.

Text and Marked Up Documents

PDF to text

Using pdftotext: pdftotext -layout input.pdf output.txt

Doc/Docx to text

Using antiword: antiword -f file.doc > file.txt

References:

Video and Images

animated gif to individual frames

Using ImageMagick: convert infile.webp outfile.png

animated webp to animated gif

Using ImageMagick: convert infile.webp outfile.gif

animated gif to mp4

Using FFmpeg: ffmpeg -i infile.gif outfile.mp4

animated webp to mp4

Using ImageMagick & FFmpeg: convert infile.webp temporary.gif; ffmpeg -i temporary.gif outfile.mp4

multiple images to animate gif

Using ImageMagick: convert -delay 20 -loop 0 *.jpg myimage.gif

svg to png

Using Inkscape: inkscape infile.svg -e outfile.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment