Python Image Reduction

Forums:

One of the problems I have is that I pic from my phone and then bluetooth to my pi.
No problem right? Well, yes. My phone does not allow me to reduce the image size to something I would use on the website.. even like 1024x768. Now I know high res pics are all the rage, but if I am just snapping off a note or drawing, I do not need anything near the minimum of 2160x2160.

The fix

Reference: Resizing an image (the python part)
Initially, I was pulling each one up in GIMP, resizing, export to new file.. totally yucky, time consuming and prone to error.
Using the tip in the linked article, I created a simply python script called i500.py.
What I added to the sample was to create a new file to keep the original file in tact... simply by injecting _500 into the file name and reassembling it.
(Note, you will have to make i500.py executable either by chmod -x i500.py or chmod 755 i500.py else run python i500.py filename.jpg)

Usage: i500.py imagefile.jpg
This will create a new image called imagefile_500.jpg in the same directory with a width of 500px x automatic height adjustment.
Interestingly, for some reason, python wants to 'list' everything... I know there is probably a work-around but did not have time to reasearch. This was a problem with the incoming file name as well as the rebuilt file name. Thus the character replacement in the code. It basically removes the [' .... '] list wrapper chars.

The Python Code

Hope it helps.

37.8269817,-122.4251495,05-20-2019 01:55:55 AM,!Slightly Lost!