vindolin / ninepatch

Slice Android style 9-patch images, resize and interactively preview them.
MIT License
20 stars 6 forks source link

Cannot render 9-patch with 0-size tiles. #5

Closed lhunath closed 1 year ago

lhunath commented 5 years ago

The following 9-patch has a padding the size of the full image and a stretch area that starts at the bottom and the left. As a result, the bottom and left tiles are either width and/or height 0.

divider 9

$ ninepatch render "$src" 200 200 out.png
Traceback (most recent call last):
  File "lib/buildtools/ninepatch", line 30, in <module>
    scaled_image = ninepatch.render(args.width, args.height)
  File "/Users/lhunath/Library/Python/2.7/lib/python/site-packages/ninepatch/__init__.py", line 293, in render
    tile = tile.resize((tile.size[0], tile_scale['y'] + extra_y), img_filter)
  File "/Users/lhunath/Library/Python/2.7/lib/python/site-packages/PIL/Image.py", line 1801, in resize
    im = im.resize(size, resample, box)
  File "/Users/lhunath/Library/Python/2.7/lib/python/site-packages/PIL/Image.py", line 1806, in resize
    return self._new(self.im.resize(size, resample, box))
ValueError: height and width must be > 0
vindolin commented 2 years ago

Totally forgot about that one, I try to look into it in the next days.

vindolin commented 2 years ago

line 88: axes = {'x': 0, 'y': 1} in init.py -> axes = {'x': 1, 'y': 1}

That would only result in the y axis being parsed twice, which is certainly not the solution to this problem.

gengyj16 commented 1 year ago

I made a pull request to fix this.

7

You can use this image for verification. tile_with_zero_size 9

vindolin commented 1 year ago

Fixed in 0.2.0 thanks to @gengyj16