Skip to content

Commit

Permalink
main branch merged rel branch
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-yucheng committed May 30, 2022
2 parents 948e894 + 05f063e commit d410213
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions aidesign_blend/libs/blenders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Last updated by username: liu-yucheng

import datetime
import imghdr
import numpy
import os
import pathlib
Expand All @@ -26,7 +25,6 @@
_BlenderContext = contexts.BlenderContext
_Callable = typing.Callable
_clamp = utils.clamp_float
_isfile = ospath.isfile
_join = ospath.join
_listdir = os.listdir
_load_json = utils.load_json
Expand All @@ -50,7 +48,6 @@
_save_text = utils.save_text
_seed = random.seed
_shuffle = random.shuffle
_what = imghdr.what

# End

Expand Down Expand Up @@ -364,6 +361,13 @@ def _parse_config(self):

self.logln("Completed parsing blenders config", 1)

def _tweak_pil_safety(self):
max_width = 65535
max_height = 65535
max_pixels = max_width * max_height
pil_image.MAX_IMAGE_PIXELS = max_pixels
self.logln(f"Tweaked PIL safety max pixels: Width: {max_width} Height: {max_height} Total: {max_pixels}", 1)

def _read_frags_path(self, frags_path):
frag_names = _listdir(frags_path)
frag_names.sort()
Expand All @@ -378,10 +382,16 @@ def _read_frags_path(self, frags_path):
frag_locs = []

for loc in orig_frag_locs:
is_file = _isfile(loc)
is_img = is_file and _what(loc) is not None
try:
image = _pil_image_open(loc)
image_format = image.format
except Exception as _:
image_format = None
# end try

if is_img:
is_image = image_format is not None

if is_image:
frag_locs.append(loc)
# end for

Expand Down Expand Up @@ -688,13 +698,6 @@ def _prep_frags_grid(self):
self.logln(f"Prepared the fragments grid: Width: {width} Height: {height}", 1)
# end if

def _tweak_pil_safety(self):
max_width = 65535
max_height = 65535
max_pixels = max_width * max_height
pil_image.MAX_IMAGE_PIXELS = max_pixels
self.logln(f"Tweaked PIL safety max pixels: Width: {max_width} Height: {max_height} Total: {max_pixels}", 1)

def _blend_block(self, block_y, block_x):
c = self._context

Expand Down Expand Up @@ -1123,11 +1126,11 @@ def prep(self):
self.logln(info)
self._read_config()
self._parse_config()
self._tweak_pil_safety()
self._prep_frags()
self._prep_matrices()
self._prep_canvas()
self._prep_frags_grid()
self._tweak_pil_safety()

info = str(
"-\n"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():
"""Main function."""
_setup(
name="aidesign-blend",
version="1.7.2",
version="1.7.3",
author="Yucheng Liu (From The AIDesign Team)",
license="Copyright (C) 2022 Yucheng Liu. GNU GPL3 license.",
description="AIDesign image fragments blending application.",
Expand Down

0 comments on commit d410213

Please sign in to comment.