img2py does not pythonize PNGs?

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them. This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

I'm probably overlooking something obvious, but have not done
this before. How can I get the PNG into Python source code so
I can use PNGs? By the way, I am using PNGs with transparency.

Thanks,
Che

Che,

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them. This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

I'm probably overlooking something obvious, but have not done
this before. How can I get the PNG into Python source code so
I can use PNGs? By the way, I am using PNGs with transparency.
  

I am just doing this in my script for PNG's, i.e. nothing special.

-a -u -i -n bottleCopy bottleCopy.png ../myimages.py

Are you getting an error/exception or is just nothing added to the images.py file?

Werner

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them.

it should -- are you sure it tried? does that script find your pngs? Where there any other pngs that got converted?

This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

imp2py stores images as png -- so what that means is that if they are already pngs, they will be moved in directly, rather than being unpacked into a wx.image, and then re-converted to a PNG.

Which brings up a thought -- it would be nice if img2py could store images as either png or jpeg -- jpeg is more suited to some image types.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

No errors, I am just getting something that doesn't appear to be the
right encoding for the PNG image. What I get is this (the PNG is
called couch_25.PNG):

couch_25 = PyEmbeddedImage(
    "iVBORwo=")
getcouch_25Data = couch_25.GetData
getcouch_25Image = couch_25.GetImage
getcouch_25Bitmap = couch_25.GetBitmap

There should be more than just that "iVBORwo=" section.

I tried it again doing it from the command prompt with no flags,
and got the same thing. Again, it's a 25x25 PNG with transparency.

Now that you and Chris say it should "just work" with PNGs, I
am confused but perhaps I can try other PNGs and see if it is
somehow related with this PNG.

Thanks,
Che

···

On Sun, Oct 4, 2009 at 3:22 AM, werner <wbruhin@free.fr> wrote:

Che,

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them. This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

I'm probably overlooking something obvious, but have not done
this before. How can I get the PNG into Python source code so
I can use PNGs? By the way, I am using PNGs with transparency.

I am just doing this in my script for PNG's, i.e. nothing special.

-a -u -i -n bottleCopy bottleCopy.png ../myimages.py

Are you getting an error/exception or is just nothing added to the
images.py file?

Hi Che,

2009/10/4 C M:

Che,

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them. This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

I'm probably overlooking something obvious, but have not done
this before. How can I get the PNG into Python source code so
I can use PNGs? By the way, I am using PNGs with transparency.

I am just doing this in my script for PNG's, i.e. nothing special.

-a -u -i -n bottleCopy bottleCopy.png ../myimages.py

Are you getting an error/exception or is just nothing added to the
images.py file?

No errors, I am just getting something that doesn't appear to be the
right encoding for the PNG image. What I get is this (the PNG is
called couch_25.PNG):

couch_25 = PyEmbeddedImage(
"iVBORwo=")
getcouch_25Data = couch_25.GetData
getcouch_25Image = couch_25.GetImage
getcouch_25Bitmap = couch_25.GetBitmap

There should be more than just that "iVBORwo=" section.

I tried it again doing it from the command prompt with no flags,
and got the same thing. Again, it's a 25x25 PNG with transparency.

Now that you and Chris say it should "just work" with PNGs, I
am confused but perhaps I can try other PNGs and see if it is
somehow related with this PNG.

Try with the SVN version of img2py. IIRC Robin fixed this issue some time ago.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On Sun, Oct 4, 2009 at 3:22 AM, werner <wbruhin@free.fr> wrote:

I just updated just the /tools folder via SVN from this point:
http://svn.wxwidgets.org/svn/wx/wxPython/trunk/wx/tools/

Now it does convert the PNG. However, the methods are now all gone.
Previously, it had methods under each PyEmbeddedImage, like this:

getmyimage16Data = myimage16.GetData
getmyimage16Image = myimage16.GetImage
getmyimage16Bitmap = myimage16.GetBitmap

...and now it is just providing the PyEmbeddedImages alone. But
I had been using these get[imagename]Bitmao() methods to actually
get the bitmaps into my app, so what should I now do?

(On a side note, that script I am running is not converting *all* the
files in the current folder through py2img. It appears to be entirely
leaving a few out for no reason I can yet figure out, and this is unrelated
to what kind of image it is (JPG, PNG, etc)).

Che

···

On Sun, Oct 4, 2009 at 6:25 PM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi Che,

2009/10/4 C M:

On Sun, Oct 4, 2009 at 3:22 AM, werner <wbruhin@free.fr> wrote:

Che,

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them. This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

I'm probably overlooking something obvious, but have not done
this before. How can I get the PNG into Python source code so
I can use PNGs? By the way, I am using PNGs with transparency.

I am just doing this in my script for PNG's, i.e. nothing special.

-a -u -i -n bottleCopy bottleCopy.png ../myimages.py

Are you getting an error/exception or is just nothing added to the
images.py file?

No errors, I am just getting something that doesn't appear to be the
right encoding for the PNG image. What I get is this (the PNG is
called couch_25.PNG):

couch_25 = PyEmbeddedImage(
"iVBORwo=")
getcouch_25Data = couch_25.GetData
getcouch_25Image = couch_25.GetImage
getcouch_25Bitmap = couch_25.GetBitmap

There should be more than just that "iVBORwo=" section.

I tried it again doing it from the command prompt with no flags,
and got the same thing. Again, it's a 25x25 PNG with transparency.

Now that you and Chris say it should "just work" with PNGs, I
am confused but perhaps I can try other PNGs and see if it is
somehow related with this PNG.

Try with the SVN version of img2py. IIRC Robin fixed this issue some time ago.

Andrea.

Possibly answering my own question... I don't see why I really need
these methods other than they were put in as a convenience. I should
be able to just refer to the image in this way, right?:

import myImages
dogimage = myImages.dogimage.GetBitmap()

Che

···

On Sun, Oct 4, 2009 at 7:28 PM, C M <cmpython@gmail.com> wrote:

On Sun, Oct 4, 2009 at 6:25 PM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi Che,

2009/10/4 C M:

On Sun, Oct 4, 2009 at 3:22 AM, werner <wbruhin@free.fr> wrote:

Che,

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them. This makes sense, since on 4/10/09
Robin wrote in the dev forum, "I've made a slight change to how
img2py works (it doesn't reprocess the image if it's already a PNG)".

I'm probably overlooking something obvious, but have not done
this before. How can I get the PNG into Python source code so
I can use PNGs? By the way, I am using PNGs with transparency.

I am just doing this in my script for PNG's, i.e. nothing special.

-a -u -i -n bottleCopy bottleCopy.png ../myimages.py

Are you getting an error/exception or is just nothing added to the
images.py file?

No errors, I am just getting something that doesn't appear to be the
right encoding for the PNG image. What I get is this (the PNG is
called couch_25.PNG):

couch_25 = PyEmbeddedImage(
"iVBORwo=")
getcouch_25Data = couch_25.GetData
getcouch_25Image = couch_25.GetImage
getcouch_25Bitmap = couch_25.GetBitmap

There should be more than just that "iVBORwo=" section.

I tried it again doing it from the command prompt with no flags,
and got the same thing. Again, it's a 25x25 PNG with transparency.

Now that you and Chris say it should "just work" with PNGs, I
am confused but perhaps I can try other PNGs and see if it is
somehow related with this PNG.

Try with the SVN version of img2py. IIRC Robin fixed this issue some time ago.

Andrea.

I just updated just the /tools folder via SVN from this point:
http://svn.wxwidgets.org/svn/wx/wxPython/trunk/wx/tools/

Now it does convert the PNG. However, the methods are now all gone.
Previously, it had methods under each PyEmbeddedImage, like this:

getmyimage16Data = myimage16.GetData
getmyimage16Image = myimage16.GetImage
getmyimage16Bitmap = myimage16.GetBitmap

...and now it is just providing the PyEmbeddedImages alone. But
I had been using these get[imagename]Bitmao() methods to actually
get the bitmaps into my app, so what should I now do?

Yes, it had converted all the other non-PNGs fine, and found my PNGs
but just encoded it as "iVBORwo=" without anything further.

But in another post here I replied to Andrea letting him know that the
SVN version of img2py does create the full PyEmbeddedImage
correctly, so problem solved I think.

Thanks,
Che

···

On Sun, Oct 4, 2009 at 4:39 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

C M wrote:

I'm trying out img2py and use a script I found online:

http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11246

...to batch convert a number of images of various formats to
Python code. It worked well for .jpgs, but for two PNG files
I had, it didn't convert them.

it should -- are you sure it tried? does that script find your pngs?
Where there any other pngs that got converted?

No errors, I am just getting something that doesn't appear to be the
right encoding for the PNG image. What I get is this (the PNG is
called couch_25.PNG):

couch_25 = PyEmbeddedImage(
    "iVBORwo=")
getcouch_25Data = couch_25.GetData
getcouch_25Image = couch_25.GetImage
getcouch_25Bitmap = couch_25.GetBitmap

There should be more than just that "iVBORwo=" section.

I tried it again doing it from the command prompt with no flags,
and got the same thing. Again, it's a 25x25 PNG with transparency.

Now that you and Chris say it should "just work" with PNGs, I
am confused but perhaps I can try other PNGs and see if it is
somehow related with this PNG.

Try with the SVN version of img2py. IIRC Robin fixed this issue some time ago.

For the record, the problem was that the files were not being opened in binary mode, and so on DOS if there was a EOF marker (Ctrl-Z) in the binary data stream then that is where the data reading would stop.

I just updated just the /tools folder via SVN from this point:
http://svn.wxwidgets.org/svn/wx/wxPython/trunk/wx/tools/

Now it does convert the PNG. However, the methods are now all gone.
Previously, it had methods under each PyEmbeddedImage, like this:

getmyimage16Data = myimage16.GetData
getmyimage16Image = myimage16.GetImage
getmyimage16Bitmap = myimage16.GetBitmap

...and now it is just providing the PyEmbeddedImages alone.

Because you fetched the trunk version which has that feature turned off by default. The version of the code on the 2.8 branch has the feature turned on by default for compatibility with the older version of img2py.

But
I had been using these get[imagename]Bitmao() methods to actually
get the bitmaps into my app, so what should I now do?

IIRC, you can use -f to turn it back on.

···

On 10/4/09 4:28 PM, C M wrote:

On Sun, Oct 4, 2009 at 6:25 PM, Andrea Gavana<andrea.gavana@gmail.com> wrote:

--
Robin Dunn
Software Craftsman

Yes. Or even just myImages.dogimage.Bitmap since the PyEmbeddedImage class has a Bitmap property.

···

On 10/4/09 4:30 PM, C M wrote:

Possibly answering my own question... I don't see why I really need
these methods other than they were put in as a convenience. I should
be able to just refer to the image in this way, right?:

import myImages
dogimage = myImages.dogimage.GetBitmap()

--
Robin Dunn
Software Craftsman