Marius Vuscan
Marius Vuscan

Reputation: 172

Python image cropping without any external library

Is there a way to read the pixel colours values of an image without using any external libraries?

Upvotes: 0

Views: 582

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207425

If you really, really must do this in Python without using a library, your simplest option is to convert your images to NetPBM format - PGM if greyscale, PPM if colour, PNM if RGBA.

You can do that with the NetPBM tools, or with ImageMagick, or libvips. See here

Then you can easily open the files with Python without libraries, see third example here.

Upvotes: 2

Yannick Funk
Yannick Funk

Reputation: 1581

Yes, there is a way. You could read the bytes of the binary file and parse its bytes according to the image format you are facing. This is very time consumptive and error-prone and due to this, I would not recommend doing it.

Upvotes: 0

Related Questions