How to avoid photo cropping by adding a border

So in Notes on ImageMagick’s –border option, I mentioned that I had photos that don’t fit on 6×4 photo paper.

Here’s an example which I uploaded to the photo printing website:
Croppedat6x4

The result is that the photo printing company has darkened the left and right of the photo, to highlight what I’m going to lose.  ie. cropped!

If only there was someway to change the photo to fit into a 6×4 print…

I’m glad you asked!


In the case of the above photo, I added a top and bottom border to make it a 6×4 photo.
new_image

To get to this point, you need:

  1. the original photos dimensions in pixels
    (see: A quick way to get the dimensions for a bunch of digital photo images.)
  2. a way to calculate the amount of border to add to the photo
    (see below)
  3. to apply the changes to a new version of the photo, so you can upload it.
    (see Notes on ImageMagick’s –border option)

Some definitions
Portrait is defined as the picture’s HEIGHT > WIDTH
Landscape is defined as the picture’s WIDTH > HEIGHT

The picture ratio (the ratio) is the large dimension divided by the small dimension.
So for a Portrait photo of 3264 (Height) x 2446 (Width), it’s ratio is 3264 divided by 2446, which is 1.33.
A 6:4 photo has a ratio of 1.5.

The amount to add to the border of a photo

We need to change the ratio of the original picture to 1.5

For Landscape photos…
For picture ratio’s <1.5, you need to add a border to the left and right.
The formula to calculate that border width for ImagicMagick is:
(WIDTH * 1.5)/2

For ratio’s >1.5, need to add a border to the top and bottom
The formula to calculate that border width for ImagicMagick is:
  (WIDTH / 1.5) – HEIGHT

For Portrait photos…
For ratio’s <1.5, need to add a border to the top and bottom of the picture.
The formula to calculate that border width for ImagicMagick is:
((WIDTH * 1.5)- HEIGHT)/2

For ratio’s >1.5, need to add a border to the left and right
The formula to calculate that border width for ImagicMagick is:
(HEIGHT / 1.5) – WIDTH