ojii / pymaging

Pure Python imaging library with Python 2.6, 2.7, 3.1+ support

Home Page:http://pymaging.rtfd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

img.save_to_path problem

FeliceMente opened this issue · comments

I'm testing the lib and, both in Python 2.7 and Python 3.2, when I use img.save_to_path(), I get this exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging/pymaging/image.py", line 76, in save_to_path
    self.save(fobj, format)
  File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging/pymaging/image.py", line 70, in save
    format_object.encode(self, fileobj)
  File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging-png/pymaging_png/png.py", line 46, in encode
    writer.write(fileobj, image.pixels)
  File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging-png/pymaging_png/raw.py", line 631, in write
    nrows = self.write_passes(outfile, rows)
  File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging-png/pymaging_png/raw.py", line 755, in write_passes
    enumrows = enumerate(rows)
TypeError: 'PixelArray3' object is not iterable

(I'm testing with png images, after installing png support)

I just tested the resize image sample code on the website (using save_to_path(9 instead of save()):

from pymaging import Image
img = Image.open_from_path('myimage.png')
img = img.resize(300, 300)
img.save_to_path('resized.png')

Hi, thanks for trying pymaging and reporting this issue.

It looks like there's a problem with some recent changes I have done to the way images are represented in Python. Could you tell me what versions exactly you were using?

Hi!

I installed pymaging using pip. pip freeze shows this (on both Python 2.7 and 3.2 virtualenvs):
-e git://github.com/ojii/pymaging.git@eb6e45a#egg=pymaging-dev
-e git://github.com/ojii/pymaging-png.git@e089e789a70c6d097745914614f14c65a9a54533#egg=pymaging_png-dev

Just to let you know, I was able to reproduce this issue with the latest version. Not sure why this isn't covered by the test suite...

This is an issue in pymaging-png, closing this issue in favor of ojii/pymaging-png#1

I also tried saving to jpeg and bmp, but got the "format not supported" message.
Code for bmp save:
from pymaging import Image

img = Image.open_from_path('myimage.png')
img = img.resize(300, 300)
img.save_to_path('resized.bmp')

note: the example on the website is wrong: it says img.save instead of img.save_to_path...

Error for bmp:
Traceback (most recent call last):
File "test.py", line 5, in
img.save_to_path('resized.bmp')
File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging/pymaging/image.py", line 76, in save_to_path
self.save(fobj, format)
File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging/pymaging/image.py", line 70, in save
format_object.encode(self, fileobj)
File "/Users/marco/Desktop/virtualenvs/py32/src/pymaging-bmp/pymaging_bmp/codec.py", line 165, in encode
raise FormatNotSupported('bmp')
pymaging.exceptions.FormatNotSupported: bmp

This is what pip freeze reports:
-e git://github.com/ojii/pymaging.git@eb6e45a#egg=pymaging-dev
-e git://github.com/ojii/pymaging-bmp.git@32ef06babd475c4ec467aefade8aa12b8d8665bc#egg=pymaging_bmp-dev
-e git://github.com/ojii/pymaging-jpg.git@57c1fa6d00cc71ad905a90939a694dd8f41d52ed#egg=pymaging_jpg-dev
-e git://github.com/ojii/pymaging-png.git@e93d57b2a7a9e866faa161b9ac09300dc58c5c16#egg=pymaging_png-dev

I installed the formats this way:
pip install -e git+git://github.com/ojii/pymaging-bmp.git#egg=pymaging-bmp
pip install -e git+git://github.com/ojii/pymaging-jpg.git#egg=pymaging-jpg
pip install -e git+git://github.com/ojii/pymaging-png.git#egg=pymaging-png

That is "expected behavior", for now. PNG was the only format i wrote an encoder for so far. I'll fix that one as soon as i can and eventually add more encoders as demand rises.

Ok, so bmp and jpg work readonly for the moment.
Thanx.