Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

[BUG] Aspect ratio should be rounded #1413

Open
leon-wbr opened this issue Apr 9, 2020 · 1 comment
Open

[BUG] Aspect ratio should be rounded #1413

leon-wbr opened this issue Apr 9, 2020 · 1 comment

Comments

@leon-wbr
Copy link

leon-wbr commented Apr 9, 2020

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
Copy link

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 😄

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

Cheers,
Your Friendly Neighborhood ProBot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant