home ~ projects ~ socials

One line of code

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

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

My apologies. I haven't added alt text to this image yet.
My apologies. I haven't added alt text to this image yet.
-- end of line --