Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

One line of code

Programming can be a pain in the ass. Take this command for example:

Code

convert -resize 310x155 -size 310x155 \
  +swap -gravity center 
  -composite input.jpg background.jpg
  output.jpg

That took three hours to figure out.

That command automatically resizes an image to fit inside a 310 pixel wide by 155 pixel high area with a background image padding out any missing space.

It's simple, now that I have it. Making it was a lot of work. The documentation was hard to parse and specific examples didn't exist.

The Result

If you're interested in what it does, here's the before and after

Initial photo of two golfers shaking hands

Two golfers shaking hands after a round after image conversion