Skip to content

Instantly share code, notes, and snippets.

@karol-majewski
Created December 17, 2025 21:01
Show Gist options
  • Select an option

  • Save karol-majewski/63f06652f161064b6a7d0132ec0e4135 to your computer and use it in GitHub Desktop.

Select an option

Save karol-majewski/63f06652f161064b6a7d0132ec0e4135 to your computer and use it in GitHub Desktop.
Merging .img files into a single PDF

Prerquisites:

imagemagick should do the trick. Install it on macOS:

brew install imagemagick

Step by step

  1. Get the images in one folder
  2. Open that folder in Terminal
  3. Run convert *.jpg title.pdf

If page numbers encoded in filenames aren’t in order, run this command instead:

convert $(ls -1 outline-functional-model-nervous-system-*.jpg | sort -t'-' -k6 -n) title.pdf

It will produc a title.pdf file in that same directory.

@karol-majewski
Copy link
Author

convert $(ls -1 MODEL_OF_THE_NERVOUS_SYSTEM-page*.jpg | sort -V) MODEL_OF_THE_NERVOUS_SYSTEM.pdf

The -V flag does "version sort" which handles numbers correctly (1, 2, 3... 10, 11 instead of 1, 10, 11, 2, 3).

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