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!

Alright, what did I do with it? A rather unsuccessful post on a Meme website, check it out: my post on 9gag. If you look at the post on mobile, you’ll probably better understand why the vertical stacking is necessary.

Leave a Reply

Your email address will not be published. Required fields are marked *