PIL or imghdr for image validation

835 Views Asked by At

I'm working on a website that will handle image uploads so I need to verify for valid images, and I have two options, I either use PIL(Pillow) or the imghdr module.

My question is, which one should I use? Since PIL is not being mantained will imghdr module do the job? Which of them is secure and/or efficient?

Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

Plese note that PIL and Pillow is not the same package. Pillow is a fork of PIL that is considered to be PIL's successor.

To work with images in a website (I assume because of your tag, that it's a django project), it's recommended to use Pillow. For example, if you want to use ImageField, it requires the Pillow library.