Tricks For Editing Photos


Posted on June 13, 2021


How to Create a New Blank Image
Let's say you want to create a new blank image of a certain colour and a certain width and height. We'll assume here that you want an image that's red in colour that's got a width of 300 pixels and a height of 200 pixels.

First install Imagemagick using these two commands:

sudo apt-get update
sudo apt-get install imagemagick

And then you can create your new blank image using this command:

convert -size 300x200 xc:red photo.jpg
How to Reduce the Size of a Photo
Let's say you have photos that are taking up a lot of space in your computer and you want to reduce their size. We'll assume here that you have a photo of several MBs and you want to reduce its size to 300 KB.

First install Jpegoptim using these commands:

sudo apt-get update
sudo apt-get install jpegoptim

And then you can reduce the size of the photo by using this command:

jpegoptim --size=300k photo.jpg
How to Crop a Photo
Let's say you have a photo of a certain width and height, and you want to slice off a section of it. For this example we'll assume that your photo has a width of 1,500 pixels and a height of 1,051 pixels, and you want to reduce its height to 1,000 pixels by slicing off a strip from the bottom. You'll have to specifiy the size of the cut out image and the offset from the upper left corner of the old image by choosing a size of 1500x1000 and an offset of 0+0.

First install Imagemagick using these commands:

sudo apt-get update
sudo apt-get install imagemagick

And then you can crop the photo using this command:

convert photo.jpg -crop 1500x1000+0+0 photo-cropped.jpg

  • If you have any questions or comments, you can contact me on Twitter: @patrickwayodi