I wanted to try a script in python & Bash. I'm a python noob, so this more about learning.
The script should resize images (using imagemacgick) to 700 pixels. The bash script for this, resize_ji.sh, is simple:
#!/usr/bin/env bash
convert "$1" -resize 700 "$1_copy.jpg"
My python script, which includes a function to grab iso time to create a file (this comes later) is this:
# First we need to import the libraries we'll be using.
import datetime
import subprocess
# We want the file name to be yyyy-mm-dd. This is how we get it.
def filename_datetime():
date = datetime.datetime.now()
filename = (date.strftime("%Y-%m-%d"))
print(filename)
def image_resize():
subprocess.call(["./resize_ji.sh","$1"], shell=True)
filename_datetime()
image_resize()
So as you can probably guess, I'm trying to path the positional parameter $1 into python; the idea is to execute it like so "./resize-image.py image.jpeg"
I'm not sure subprocess.call is the way to go here either. Not sure what I should use or how it is called so I can look it up.