Embedding an image for Instagram

This is a short python program which uses PIL (Python imaging library or Pillow) to perform its magic. Cut and paste or email me for the source (Or even better sign up for my page and I’ll use that email).

It takes an input image and places it in a 2048×2048 square with a white background.

#!/usr/bin/python3
#
#  (c) 2023 Treadco
#

import numpy as np
import sys
from PIL import Image

def main():
    try:
      image = Image.open(sys.argv[1])
    except IndexError:
      print("Could not open the input \nUsage to_instagram inputfile outputname")
      sys.exit()

    if len( sys.argv) < 3:
        outputfilename = "output.jpg"
    else: 
        outputfilename = sys.argv[2]

    iarray = np.array(image.convert("RGB"))
    nx = iarray.shape[0]
    ny = iarray.shape[1]
    inew = Image.new( "RGB", [2048,2048], (255,255,255))
   
    if nx > ny :
        simage = image.resize([ int((2048.*ny)/nx),2048 ])
        inew.paste( simage, [int((2048-int((2048.*ny)/nx))/2),0])
    else:
        simage = image.resize([2048, int((2048.*nx)/ny) ])
        inew.paste( simage, [0,int((2048-int((2048.*nx)/ny))/2)])

    inew.save(outputfilename)
    
 

main()

A Kickstarter – get in on it!

I’ve pre-released a kickstarter to fund a photobook.

https://www.kickstarter.com/projects/photorob/wildlife-glimpsed-an-artbook-of-wild-animals-and-plants

About 50 pages of photos and commentary – including where to see these animals and some of their natural history.

A Mascot’s Tale

I was found lying on a country road, in Cornwall, on my face and in the mud.

Not a very dignified pose, I’d say, certainly below the dignity of any proper animal.

So a kind stranger propped me on a wall in front of a house to see if anyone claimed me. They didn’t so he took me home, cleaned me up, and adopted me as his mascot. 

I must have been too fierce for anyone else.

Here I am resting after my journey.

My new people took me on adventures like the South Coast footpath:

and the sea:

This is by a town called “Mazel” and spelled “Mousehole.” Isn’t that a funny name? I didn’t see any mice.

I had a cold drink on one hot afternoon. That ginger-ale tasted so good. It’s no wonder that it’s by appointment to the Prince of Wales.

They also took me up into the hills – which I now know aren’t very high in Cornwall – but they seemed it at the time.

Finally they took me to the airport. Here I’m watching the activity on the runway.

and here I’m posing in front of the plane we flew on.

It was a good thing they didn’t stuff me in the luggage because that didn’t fly with us.

I’ll add more about my adventures in my new home later.