Please note .jpeg and .jpg are the exact same format, so there's no need to convert from .jpeg to .jpg and vice versa.
I got tired of using a web converter like https://convertio.co/ to convert images, so I made my own.
Everything works now, but I might update it later.
My initial intent when coding this was just simply making a function that I could import into iPython and then give the function the following arguments:
- A path to the image I want to convert
- A format I want to convert it in
As I began coding, I thought of more ideas and use cases. So currently debating myself if I should just leave this as a function or update features such as adding more image formats or adding a gui, the ideas are endless tbh.
To use this you have two options:
- Copy and paste the entire function into an interpreter like iPython
- Import it into your interpreter directly
Then call the function with the arguments. Example:
convert_image('/home/user/test/chad.webp', '.jpg')
You should see chad.wbp.jpg in the directory now.
When I was testing this program, I made sure it actually changed formats, it works.
Will try to convert this code into something more modular later so it can be easily copied and pasted when making modules, classes, functions, etc.
For now, enjoy and hope you find this useful for either converting images or learning Python!