Created
July 10, 2023 20:44
-
-
Save bartread/1f93b3235d35f6f4e9ef97a13cd2c12e to your computer and use it in GitHub Desktop.
Useful ImageMagick commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Note, if using Cygwin, ImageMagick is *not* installed by default and will need to | |
# be manually selected during the install. | |
# Using these turns out to be much less effort than firing up GIMP and, moreover, | |
# all of these operations are of course scriptable for batch processing of images. | |
# RESIZING AN IMAGE | |
# Note that if file extensions don't match, the image will be converted | |
# to the format implied by the output file extension. | |
convert source.png|jpg|etc -resize WIDTH_IN_PIXELSxHEIGHT_IN_PIXELS output.png|jpg|etc | |
# RESIZING EXAMPLE | |
convert close_all_positions_256.png -resize 128x128 close_all_positions_128.png | |
# SWAPPING COLOUR CHANNELS | |
# Turns out to be super-useful. Here's an example that swaps the red and | |
# green channels: | |
convert close_all_positions_256.png \( +clone -channel G -fx R \) +swap -channel R -fx v.G close_all_profitable_positions_256.png | |
# OVERLAYING IMAGES | |
# The following example overlays one image on another. The second image | |
# is also resized and placed over the bottom right corner of the first: | |
magick convert close_all_profitable_positions_256.png play_256.png -gravity Center -geometry 128x128+64+64 -composite -resize 256x256 close_all_profitable_positions_and_reinstate_as_orders.png | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment