Stitching and Appending Images (Screenshots / Memes) Vertically with Imagemagick

Stitching or stacking images can be relevant for publishing them to some websites. Meme sites like 9gag or similar have a specific layout format for “longposts” (very long images) that are displayed without scaling and are often used as a format for webcomics or a compilation of images.

I was wondering if anyone on there was interested in photography and decided to stack some of my yet unpublished pictures of the Axel Towers in Copenhagen. Turns out nobody really cares about photography there, but hey, if you have more appropriate material, I'm sharing the imagemagick command here.

convert source/* -background black -splice 0x50 -append -crop -0+50 -gravity center result.jpg

This is what my source folder looks like:

I saw a really neat trick and I kind of stole the splice and crop part from this German dude called Fritz and I really like how he's listing every parameter to the convert command, so I'll break up this command too.

  • convert one of the imagemagick binaries, duh.
  • source/* this directory contains all my images
  • -background black if anything in the new image is not covered by the photos, fill with that colour, HTML hex codes work like this "#000000"
  • -splice 0x50 spacing of 50px between images vertically
  • -append append source images onto one canvas
  • -crop -0+50 crop off the border that's only supposed to be between source images
  • -gravity center if you have some high format images that might not go all the way to the x axis sides, center them
  • result.jpg the image to create from your other images

Obviously this deservers some tweaking to match the source resolution of your images (pay attention to splice and crop and to keep them the same). Let me know what you're working on if you find this post!

Tagged with: #9gag #imagemagick

Thank you for reading! If you have any comments, additions or questions, please tweet or toot them at me!