hanzhi713 / image-collage-maker

A photo mosaic (pixel collage) maker. Use all your friends' profile pictures to approximate your profile picture! 如何用 Python 制作一个炫酷的微信好友图
MIT License
156 stars 14 forks source link

BUG (GUI): Loading Tiles Generates Error if "Infer height" is checked #15

Closed Pizzanomicon closed 2 years ago

Pizzanomicon commented 2 years ago

For most directories (with very few exceptions), if "infer height" is checked, the [Inferring size]: bar jumps immediately to 100% and an error message appears. This occurs in 48/53 directories, cannot isolate what traits make this happen:


Error

Traceback (most recent call last): File "E:\MosaicEnv\gui.py", line 270, in load_img_action imgs = mkg.read_images(fp, sizes, recursive.get(), mp.Pool(cpu_count() // 2), resize_opt.get(), auto_rotate.get()) File "E:\MosaicEnv\make_img.py", line 795, in read_images most_freq_ratio = 1 / sizes[-1][1] IndexError: list index out of range


OK

Environment is Python 3.10.3 with the following libraries: altgraph==0.17.2 certifi==2021.10.8 charset-normalizer==2.0.12 cloudscraper==1.2.60 colorama==0.4.4 cycler==0.11.0 fonttools==4.32.0 future==0.18.2 idna==3.3 imagesize==1.3.0 kiwisolver==1.4.2 lapjv==1.3.1 matplotlib==3.5.1 numpy==1.22.3 opencv-contrib-python==4.5.5.62 opencv-python==4.5.5.64 packaging==21.3 pefile==2021.9.3 Pillow==9.1.0 pyinstaller==4.8 pyinstaller-hooks-contrib==2022.3 pyparsing==3.0.8 python-dateutil==2.8.2 pywin32-ctypes==0.2.0 random-user-agent==1.0.1 requests==2.27.1 requests-toolbelt==0.9.1 six==1.16.0 tqdm==4.64.0 typing==3.7.4.3 urllib3==1.26.9

Pizzanomicon commented 2 years ago

CSV branch

hanzhi713 commented 2 years ago

This might be caused by the fact that the imagesize library is unable to infer the size of all your images (tiles). Can you attach some sample images? If it's not possible, I can work on a "backup solution" for the case when imagesize fails to infer the size of the majority of images in a folder.

hanzhi713 commented 2 years ago

I just wrote a fallback function to read entire images to get the size (in case the size cannot be inferred from the metadata). You can pull the code from the csv branch. Could you please help me to test it?

Pizzanomicon commented 2 years ago

Sorry for absence/lag- It appears to still be bugged, now erroring out with:

---------------------------
Error
---------------------------
Fail to infer size. All of your images are in an unsupported format!
---------------------------
OK   
---------------------------

Note that if "infer height" is not checked, the tiles load and are used just fine. This occurs with directories containing only jpegs, and directories containing only pngs.

I found that nearly all of my collections have this bug- and created a folder with only 3 images, which still exhibits the error:

Buggedi-smallset.zip

hanzhi713 commented 2 years ago

I found the bug. These two deleted lines: https://github.com/hanzhi713/image-collage-maker/commit/33f9ee5574cfcd4c31f1484e0a0972e49ba12015#diff-356786599b38a46ce84bfa9b9b9c759b58d0cece14fb110424104c5dc03f2903L785 removed the size info of all square-sized images.

Now infer size should be working. By the way, please use the master branch code now.