ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.69k stars 1.47k forks source link

[BUG] Aspect ratio should be rounded #1413

Open leon-wbr opened 4 years ago

leon-wbr commented 4 years ago

Example file

def upload_picture(bot):  # Automatically post a pic in 'pics' folder
    pics = glob(pics_path + "*.jpg")
    pics = sorted(pics)
    try:
        for pic in pics:
            if pic in posted_pic_list:
                continue

            pic_name = pic[:-4]
            caption_file = pic_name + ".txt"

            if os.path.isfile(caption_file):
                with open(caption_file, "r") as file:
                    caption = file.read() + "\n\n" + config.FOLLOW_MESSAGE + "\n" + config.PICS_HASHTAGS
            else:
                caption = config.FOLLOW_MESSAGE + "\n" + config.PICS_HASHTAGS

            bot.upload_photo(pic, caption=caption)
            if bot.api.last_response.status_code != 200:
                print(bot.api.last_response)
                break

            if pic not in posted_pic_list:
                posted_pic_list.append(pic)
                with open(config.POSTED_PICS_FILE, "a") as f:
                    f.write(pic + "\n")
                bot.logger.info("Succesfully uploaded: " + pic)
                break
    except Exception as e:
        bot.logger.error("Couldn't upload pic")
        bot.logger.error(str(e))

Describe the bug

Any file with exact 4:5 ratio won't be uploaded because its aspect ratio is 0.7998 instead of 0.8. This is clearly a rounding issue, any of those pictures can be uploaded without issues on the phone.

Log

FOUND: w:1638 h:2048 r:0.7998046875
2020-04-09 22:34:40,710 - ERROR - Photo does not have a compatible photo aspect ratio.
2020-04-09 22:34:40,711 - INFO - Photo 'pics\IMG_4290.jpg' is not uploaded.
2020-04-09 22:34:40,713 - INFO - Succesfully uploaded: pics\IMG_4290.jpg
2020-04-09 22:34:40,716 - INFO - Total requests: 11

To Reproduce

Simply try uploading an image with exactly 4:5 ratio.

Expected behavior

Upload the image (or maybe even crop if necessary?)

Additional context

Version

Python version (python -v):

Operating Systeem: Win/Linux/MacOS

duplicate-issues[bot] commented 4 years ago

Hey @leon-wbr,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot