Python Forum
image format in python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: image format in python (/thread-782.html)

Pages: 1 2


image format in python - Skaperen - Nov-05-2016

i was looking through some old C functions (i am planning to write them in python) and one of them stood out as needing some more python knowledge Doh this function takes a 2D array pixels in RGB and produces a 16777216 color GIF file Shifty   i may have to implement this for python as a C function Evil  but what i really need to know is how python programmers store their images in memory while working with them  Drool   can someone tell me or point me to documentation? Pray

oh, and, yes GIF really can do 24-bit color Dance   but many program can't handle them. Sad


RE: image format in python - Mekire - Nov-05-2016

(Nov-05-2016, 08:49 AM)Skaperen Wrote:  but what i really need to know is how python programmers store their images in memory while working with them

Well if you are doing stuff that borders on computer vision then generally we use numpy arrays.  The OpenCV library is the way to go if doing anything complicated (note the format is BGR annoyingly).

Really depends what you are doing.  Pillow might be enough or even Pygame, but if you are doing heavy image manipulation, numpy (and numpy back libraries) are the way to go.


RE: image format in python - wavic - Nov-05-2016

(Nov-05-2016, 09:12 AM)Mekire Wrote:
(Nov-05-2016, 08:49 AM)Skaperen Wrote:  but what i really need to know is how python programmers store their images in memory while working with them

Well if you are doing stuff that borders on computer vision then generally we use numpy arrays.  The OpenCV library is the way to go if doing anything complicated (note the format is BGR annoyingly).

Really depends what you are doing.  Pillow might be enough or even Pygame, but if you are doing heavy image manipulation, numpy (and numpy back libraries) are the way to go.

I will mention Pillow. It's a 3th party library which is designed for an image processing.


RE: image format in python - Skaperen - Nov-06-2016

so basically, if you had a task to insert some pixels in an image file, you might implement it as loading/converting that file to pixels using pillow, modify the pixels, then dump/covert it back to a file of the same format using pillow?

suppose you had 2 image processing programs (in python) running at the same time an one needs to transfer an image to the other over an existing TCP connection (these programs might be running on separate computers). what format might you send the image in? (suppose security is good enough to trust pickle). can a pillow Image object be pickled?


RE: image format in python - wavic - Nov-06-2016

TCP can transfer binary data, right? I don't know for Pillow but native Python can handle this. If not, there are twisted, requests, pyzmq. For example.


RE: image format in python - Larz60+ - Nov-06-2016

Data Encryption?


RE: image format in python - wavic - Nov-06-2016

For sure! PyNaCl


RE: image format in python - Larz60+ - Nov-06-2016

asking if the goal is image embedded encryption


RE: image format in python - wavic - Nov-06-2016

If the image goes to the network or some data, no matter where it goes, it has to be encrypted.


RE: image format in python - Larz60+ - Nov-06-2016

asking skaperen 'if the goal is image embedded encryption '