Skip to content

Commit

Permalink
Have PIL except on unsupported files
Browse files Browse the repository at this point in the history
  • Loading branch information
theFroh committed Oct 13, 2015
1 parent 51f3f57 commit 39e90ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Binary file modified imagepacker/__pycache__/imagepacker.cpython-34.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion imagepacker/imagepacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,18 @@ def pack_images(image_paths, background=(0,0,0,0), format="PNG", extents=None, t
blocks = []
image_name_map = {}

image_paths = [path for path in image_paths if path is not None]
image_paths.sort() # sort so we get repeatable file ordering, I hope!
# pprint(image_paths)

for filename in image_paths:
print("opening", filename)
image = Image.open(filename)

image = image.transpose(Image.FLIP_TOP_BOTTOM)
# rescale images
changes = None
if extents:
if extents and extents[filename]:
# print(filename, image.size)
image, changes = crop_by_extents(image, extents[filename], tile, crop)

Expand Down
7 changes: 4 additions & 3 deletions objuvpacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ def uv_wrap(self):
return (self.max_x - self.min_x, self.max_y - self.min_y)

def tiling(self):
if self.min_x < 0 or self.min_y < 0 or self.max_x > 1 or self.max_y > 1:
return (self.max_x - self.min_x, self.max_y - self.min_y)
if self.min_x and self.max_x and self.min_y and self.max_y:
if self.min_x < 0 or self.min_y < 0 or self.max_x > 1 or self.max_y > 1:
return (self.max_x - self.min_x, self.max_y - self.min_y)
return None

def __repr__(self):
Expand Down Expand Up @@ -244,7 +245,7 @@ def __repr__(self):

else:
textents = None

# pprint(dmaps)
# pack and save textures, get info about new coordinate changes
print("\ncreating packed texture")
if additional: # additional images
Expand Down

0 comments on commit 39e90ec

Please sign in to comment.