You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I have to thank you for your script, since it pointed me towards the steps on properly converting colorized PDFs to monochrome PDFs.
However, the script looks extremely overcomplex and written by someone, who tinkered around "until it works" without knowing the full potential of bash scripting. I do not blame you for that: We all began like that.
This is why I wanted to contribute with a simplified and optimized version, that does everything way more elegant and also faster, utilized parallel processing.
IN=my_colorized.pdf
OUT=./out.pdf
# Make sure, we have some temp directory to work in
TMP="/tmp/pdfimg"
mkdir -p $TMP
# Convert PDF to single images
pdfimages ${IN} ${TMP}/im
# Convert with limited amount of threads using parallel
THREADS=4
find ${TMP} -name "*.ppm" | parallel -I% -j ${THREADS} --max-args 1 convert -monochrome % %.pdf
# Combine
pdfunite ${TMP}/*.pdf ./${OUT}
# Cleanup
rm ${TMP}/*
The only additional dependency here is GNU parallel, that distributes the BW conversion tasks to multiple threads in order to speed it up.
I also suggest, that you follow the unix philosophy of using arguments as input parameters to your program.
The text was updated successfully, but these errors were encountered:
First, I have to thank you for your script, since it pointed me towards the steps on properly converting colorized PDFs to monochrome PDFs.
However, the script looks extremely overcomplex and written by someone, who tinkered around "until it works" without knowing the full potential of bash scripting. I do not blame you for that: We all began like that.
This is why I wanted to contribute with a simplified and optimized version, that does everything way more elegant and also faster, utilized parallel processing.
The only additional dependency here is GNU parallel, that distributes the BW conversion tasks to multiple threads in order to speed it up.
I also suggest, that you follow the unix philosophy of using arguments as input parameters to your program.
The text was updated successfully, but these errors were encountered: