CLI commands¶
SGC Automated App Input Checklist¶
Before importing¶
- Check all H1/H2 combos (Only lessons should have an H1 before the H2 title [not Appendices, Biblio etc])
- Run VBA script to convert textboxes to footnotes (
ConvertTextBox2Footnote) - Convert doc to HTML (do NOT use the
-sswitch for pandoc) - Import to SGC admin course panel
After importing¶
- Add course description, title, etc
- Add images
- Add Appendix, Bibliography, etc
- Add review questions
Compress PDF files¶
Compress a PDF file to save bandwidth (run in Ubuntu 22.04)
(Uses optimize level "2" because 3 creates artifacts/boxes around transparent images in Apple Safari)
OCR PDF files for Telugu¶
Run tesseract (via ocrmypdf) on a PDF file and also output a plaintext file:
Install jbig2 codec: https://launchpad.net/~alex-p/+archive/ubuntu/jbig2enc
Convert PDF files to JPG thumbnails¶
magick mogrify -density 300 -colorspace sRGB -format jpg -path thumbnails -resize "647x647>" -alpha remove -background white *.pdf[0]
Note
- Manually create the 'thumbnails' dir first, otherwise it won't put the thumbnails there.
- We're resizing to 647px on the long end. The
>at the end of the resize command is what keeps the aspect ratio right. - The [0] at the end of the pdf filename is what selects just the first page of the PDF (e.g. if we're creating JPG thumbnails of course cover PDFs.)
- The
-alpha remove -background whiteis for certain PDFs that apparently had some transparency applied and were coming out with black backgrounds.
Convert PNG files to optimized JPG¶
Or in a recursive batch file:
@echo off
setlocal enabledelayedexpansion
for /r %%F in (*.png) do (
magick "%%F" -quality 80 -define jpeg:optimize-coding=true "%%~dpnF.jpg"
del "%%F"
)
Convert JPG files to B&W¶
Convert color JPG files to SGC teal tint¶
Create a folder called converted first.
mkdir converted
for %f in (*.jpg) do magick "%f" -grayscale Rec601Luminance -fill "#4693a5" -colorize 55 -level 10%,70% "converted\%f
Crop Tiles from Images¶
Crop tiles from images (e.g. for BED bridge diagram Publisher files)
- Install imagemagick if it's not installed already.
- Save the full size JPG from Publisher.
- Go the folder where the JPG is (in File Explorer) and right-click in a blank spot, then click "Open in Terminal"
- Run the command below:
The crop6x1@ tells it to crop 6 tiles equally spaced.
The -scene 1 part tells it to start numbering from 1 instead of 0.
Convert SVG to EMF¶
Using Inkscape, as shown in this answer.
Create a favicon from an SVG file¶
Create a 32x32 favicon with a transparent background from an SVG file (change the density to change ico resolution).
Use the following command to get different sizes:
Add meaningful metadata to PDF files¶
Use exiftool to recursively process all PDF files in a folder, adding the filename as the "Title" of the PDF file, and "Shepherds Global Classroom" as the Author and Creator. (The idea came from this exiftools forum post.)
exiftool.exe -P -r -progress -overwrite_original -ext PDF "-Title<Basename" -Author="Shepherds Global Classroom" -Creator="Shepherds Global Classroom" .
Note
You can run exiftool on the server too. Just download the lastest binary from Github (you'll want the amd64-glibc version for Hostinger). Make it executable, then make sure to set a writable temp directory: export TMPDIR=temp before running your command.