Imgconvren — Package to help with converting and renaming your images

Charles Samuel R
2 min readOct 12, 2020

This post explains about a package I had created which will help in converting images into a single format and rename them easily.

When I was tasked to do binary classifier for images, we did not have a ready-made data for the given requirements.

So we had to collect images on our own to get the data(It was a pretty small dataset so we didn’t have to stress on it that much). We set a target of just 100 images and a split of about 80/20 for the train and validation respectively.

The web being how it is, we managed to get a wide variety of images alright but all of them were a different variety in terms of the name(That was to be expected) and extension with jpg’s, png’s, and even something called WebM.

I managed to automate the renaming and conversion of the images to one format(JPG to be exact) using Pillow’s functionality that I found from the article here:

Doing this code got me thinking: Why not automate it as a package? This would save us a few lines of code and all we need is to install the package and we were done.

And that’s how I got the idea for imgconvren.

This in the end just relies on the functionality of Pillow(PIL).

So how it works is:

You create a Renamer object.

import convrenr = Renamer()

The first version is a bit of a workaround at the moment and the reason why you see convren is, let’s just say that I had a few failed attempts 😅.

Once you declare the Renamer object, we can call the conv_ren method in the class now as shown:

r.conv_ren('file_path', 'jpeg', 'test') 

This line will convert and rename the images as test(or any other name you choose)

Note: The file path here should be absolute.

And that is it. You will be able to convert and rename pretty easily using Pillow

You can find the project on PyPi here:

The source code can be found here:

In terms of revisions, something I’ve been meaning to do is maybe bringing it to a single function when initializing the Renamer class. Any other improvements can be raised in the GitHub repo.

That’s it for this article.

--

--

Charles Samuel R

My primary focus has been everything Data Science and Data Analytics and now more recently NLP and its applications and other small research here and there