GithubHelp home page GithubHelp logo

Comments (4)

blueset avatar blueset commented on June 12, 2024 1

Logic from wolfsilver/efb-telegram-master.

https://github.com/wolfsilver/efb-telegram-master/blob/99668b60f7ff7b6363dfc87751a18281d9a74a09/efb_telegram_master/utils.py#L25-L28

        "img_min_size": 1600,       # 最短边>1600
        "img_max_size": 1200,       # 最长边>1200,且长短边比例>3.5
        "img_size_ratio": 3.5,
        "img_size_max_ratio": 10,

https://github.com/wolfsilver/efb-telegram-master/blob/99668b60f7ff7b6363dfc87751a18281d9a74a09/efb_telegram_master/slave_message.py#L142-L163

            elif msg.type == MsgType.Image:
                sendImageAsFile = False
                try:
                    pic_img = Image.open(msg.path)
                    max_size = max(pic_img.size)
                    min_size = min(pic_img.size)
                    img_ratio = max_size / min_size


                    if min_size > self.flag("img_min_size"):
                        sendImageAsFile = True
                    elif max_size > self.flag("img_max_size") and img_ratio > self.flag("img_size_ratio"):
                        sendImageAsFile = True
                    elif img_ratio >= self.flag("img_size_max_ratio"):
                        sendImageAsFile = True
                except Exception as e:
                    pass
                if self.flag("send_image_as_file") or sendImageAsFile:
                    tg_msg = self.slave_message_file(msg, tg_dest, msg_template, old_msg_id, target_msg_id,
                                                     reply_markup)
                else:
                    tg_msg = self.slave_message_image(msg, tg_dest, msg_template, old_msg_id, target_msg_id,
                                                      reply_markup)

from efb-telegram-master.

blueset avatar blueset commented on June 12, 2024

Looking for an appropriate threshold for this purpose.

from efb-telegram-master.

milkice233 avatar milkice233 commented on June 12, 2024

Telegram performs poorly when compressing the image file which length-width ratio is too high, like long picture or a large website screenshot captured by Chrome. This kind of image should be properly compressed, or alternatively sent as a file.

from efb-telegram-master.

blueset avatar blueset commented on June 12, 2024

Copied Wolfsilver's solution here.

from efb-telegram-master.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.