Skip to content

Instantly share code, notes, and snippets.

@SubOptimal
Last active April 18, 2022 19:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubOptimal/addb65cb10b8846f3edefd4a8100a315 to your computer and use it in GitHub Desktop.
Save SubOptimal/addb65cb10b8846f3edefd4a8100a315 to your computer and use it in GitHub Desktop.
create perspective screenshot

On Twitter, Will McGuan posted a perspective screenshot.

This gist provides few basic steps, using ImageMagick, to produce some similar looking.

Following steps were processed.

  • starting with a screenshot of the Rich CLI help in a terminal

image

  • create a perspective view of the screenshot

image

  • add shadow to the perspective

image

  • create a gradient for the background

image

  • combine both images

image

The script create.sh process all the mentioned steps.

note: The aim was to provide the basic steps and not a fully optimized version of the workflow. Some imagemagick steps could be combined, but were not for clarity.

#!/bin/bash
set -o errexit
screenshot=rich-help-screenshot.png
perspective=01-perspective.png
shadow=02-shadow.png
gradient=03-gradient.png
final=04-final.png
# create perspective view
convert ${screenshot} -matte -virtual-pixel transparent -distort Perspective '0,0 0,0 987,0 987,70 987,810 987,720 0,810 0,810' ${perspective}
# add shadow to the perspective view
convert ${perspective} \( +clone -background black -shadow 80x10+5+10 \) +swap -background none -layers merge +repage ${shadow}
# create a color gradient for the background
convert -size 1027x850 -define gradient:direction=57 'gradient:rgb(54,200,150)-rgb(20,90,160)' ${gradient}
# combine both images
convert -page +0+0 ${gradient} -page +0+0 ${shadow} +page -alpha Set -virtual-pixel transparent -background None -flatten ${final}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment