diegorep / pypng

Automatically exported from code.google.com/p/pypng
0 stars 0 forks source link

DeprecationWarning #58

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Warnings I receive when capturing an image with a firewire card and then
saving it as png using pypng:

/usr/local/lib/python2.6/dist-packages/png.py:765: DeprecationWarning:
struct integer overflow masking is deprecated
  extend(row)
/usr/local/lib/python2.6/dist-packages/png.py:784: DeprecationWarning:
struct integer overflow masking is deprecated
  extend(row)

What steps will reproduce the problem?

from pydc1394 import DC1394Library, Camera
import png
#capturing stuff
cams = DC1394Library().enumerate_cameras()
cams[0] = Camera(DC1394Library(), cam0_handle['guid'], (1024, 768, "Y16"))
cam0.start()
img = cam0.shot()
cam0.stop()
plotname = "test_" + str(m) + ".png"
#png related stuff
f = open(plotname, 'wb')
png.Writer(mode[0], mode[1], greyscale=True, bitdepth=16).write(f, img)
f.close()

What version of the product are you using? On what operating system?
using 0.0.11 pypng on Ubuntu 9.10, Python 2.6

Original issue reported on code.google.com by grimmw...@german-borg.de on 18 Jan 2010 at 2:22

GoogleCodeExporter commented 8 years ago
I'm guessing that img is a numpy array?  Is that so?  What version of numpy are 
you using, and what is the dtype 
of the img array?

Basically, I'd love to fix this, but it's something to do with numpy integer 
types not behaving properly with 
Python's array and struct modules. See PyPNG's Issue 44 and Python's issue 2263 
http://bugs.python.org/issue2263 for more gory details.

Original comment by d...@pobox.com on 19 Jan 2010 at 8:44

GoogleCodeExporter commented 8 years ago
There is a workaround.  Add this to your code:

import warnings;warnings.filterwarnings('ignore','.*integer 
*overflow',DeprecationWarning,'png')

It suppresses the DeprecationWarning.  Since this seems to be due to a bug in 
numpy (or misfeature at best), I'm 
considering adding this to PyPNG.

Original comment by d...@pobox.com on 19 Jan 2010 at 1:56