← Back to team overview

phatch-dev team mailing list archive

[Bug 440273] Re: Tamogen ZeroDivisionError

 

Try this:
=== modified file 'phatch/other/tamogen.py'
--- phatch/other/tamogen.py     2009-09-21 04:26:34 +0000
+++ phatch/other/tamogen.py     2009-10-02 05:11:31 +0000
@@ -39,7 +39,7 @@
     assert filltype in FILL_TYPES

     fill_size = (x_pix, y_pix)
-    num_squares = (x_squares, y_squares)
+    num_squares = (min(x_squares, x_pix), min(y_squares, y_pix))
     final_img = Image.new(im.mode, fill_size)

     fill_section_size = get_section_size(fill_size, num_squares)

-- 
Tamogen ZeroDivisionError
https://bugs.launchpad.net/bugs/440273
You received this bug notification because you are a member of Phatch
Developers, which is subscribed to Phatch.

Status in Phatch = Photo & Batch!: Confirmed

Bug description:
While running the test suite on the tamogen action I got this error:

ERROR:actionlist: /home/nadia/projects/phatch/tests/output/actionlists/convert_mode_tamogen_Mode=1_FillType=Folder_Rows=1000_Columns=1.phatch generated the following logs:
Error 0:Can not apply action Tamogen on image 'fish.gif' in folder:
/home/nadia/projects/phatch/tests/input

float division

Action:{'fields': {'Canvas Height': '100%',
            'Canvas Width': '100%',
            'Columns': u'1',
            'Fill Folder': '<folder>/<subfolder>',
            'Fill Image': '<path>',
            'Fill Type': u'Folder',
            'Rows': u'1000',
            '__enabled__': 'yes'},
 'label': 'Tamogen'}

Traceback (most recent call last):
  File "/home/nadia/projects/phatch/phatch/core/api.py", line 608, in apply_action_to_photo
    photo = action.apply(photo, read_only_settings, cache)
  File "/home/nadia/projects/phatch/phatch/core/models.py", line 106, in apply
    photo.get_layer().apply_pil(self.pil, **values)
  File "/home/nadia/projects/phatch/phatch/core/pil.py", line 709, in apply_pil
    self.image = function(self.image, *arg, **keyw)
  File "/home/nadia/projects/phatch/phatch/actions/tamogen.py", line 42, in mosaic
    canvas_width, canvas_height, fill_image, fill_folder)
  File "/home/nadia/projects/phatch/phatch/other/tamogen.py", line 81, in mosaic
    fill_img, tone_diff = fill_images.findClosestImageAndToneDiff(bsection)
  File "/home/nadia/projects/phatch/phatch/other/tamogen.py", line 108, in findClosestImageAndToneDiff
    image_avg = sum(Stat(diff_image).mean)
  File "/usr/lib/python2.5/site-packages/PIL/ImageStat.py", line 64, in __getattr__
    v = getattr(self, "_get" + id)()
  File "/usr/lib/python2.5/site-packages/PIL/ImageStat.py", line 120, in _getmean
    v.append(self.sum[i] / self.count[i])
ZeroDivisionError: float division
*

I'm attaching the actionlist and the image to reproduce the error.



References