User:SnpoSuwan/Extracting images from PDFs

From sona pona, the English–Toki Pona wiki

I spent precisely too long trying to do this, but I finally did it! here's how. thanks to jan Pensa and his programmer friend Robin for teaching me how to. sorry that this article is very lazy, it is mostly for me to not forget everything

Download

first of all, download the PDF that you would like to extract the images from. outside of that, useful tools that you need include:

  • pdfimages
  • ImageMagick
  • Inkscape

Extract

using pdfimages, open the command line and type this, substituting original_pdf and image with the desired file paths. by the way, this is all on Windows so it might work differently for you, sorry

cd C:\Program Files\Xpdf\bin64
pdfimages.exe -j original_pdf.pdf image

and it will spit out a lot of images, but oh no they are all separated into the colour and alpha channels

Merge

so now using ImageMagick, try the command below for all the images, substituting image, mask and output with the desired names. quotes are important!!!

magick "image" "mask" -alpha off -compose copy-opacity -composite output.png

SVGs

for this, just go read this page, it explains it way better than I could.