mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Further document automatic photo resizing
This commit is contained in:
parent
fd24f7087e
commit
5c85f830bd
|
@ -1,3 +1,4 @@
|
|||
cryptg
|
||||
pysocks
|
||||
hachoir3
|
||||
pillow
|
||||
|
|
|
@ -31,6 +31,7 @@ class _CacheType:
|
|||
|
||||
|
||||
def _resize_photo_if_needed(file, is_image, width=1280, height=1280):
|
||||
# https://github.com/telegramdesktop/tdesktop/blob/12905f0dcb9d513378e7db11989455a1b764ef75/Telegram/SourceFiles/boxes/photo_crop_box.cpp#L254
|
||||
if (not is_image
|
||||
or PIL is None
|
||||
or (isinstance(file, io.IOBase) and not file.seekable())):
|
||||
|
@ -164,6 +165,11 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
If the ``hachoir3`` package (``hachoir`` module) is installed,
|
||||
it will be used to determine metadata from audio and video files.
|
||||
|
||||
If the `pillow` package is installed and you are sending a photo,
|
||||
it will be resized to fit within the maximum dimensions allowed
|
||||
by Telegram to avoid ``errors.PhotoInvalidDimensionsError``. This
|
||||
cannot be done if you are sending :tl:`InputFile`, however.
|
||||
|
||||
Returns:
|
||||
The `telethon.tl.custom.message.Message` (or messages) containing
|
||||
the sent file, or messages if a list of them was passed.
|
||||
|
|
|
@ -171,7 +171,7 @@ PHOTO_CONTENT_URL_EMPTY,400,The content from the URL used as a photo appears to
|
|||
PHOTO_CROP_SIZE_SMALL,400,Photo is too small
|
||||
PHOTO_EXT_INVALID,400,The extension of the photo is invalid
|
||||
PHOTO_INVALID,400,Photo invalid
|
||||
PHOTO_INVALID_DIMENSIONS,400,The photo dimensions are invalid
|
||||
PHOTO_INVALID_DIMENSIONS,400,The photo dimensions are invalid (hint: `pip install pillow` for `send_file` to resize images)
|
||||
PHOTO_SAVE_FILE_INVALID,400,The photo you tried to send cannot be saved by Telegram. A reason may be that it exceeds 10MB. Try resizing it locally
|
||||
PHOTO_THUMB_URL_EMPTY,400,The URL used as a thumbnail appears to be empty or has caused another HTTP error
|
||||
PIN_RESTRICTED,400,You can't pin messages in private chats with other people
|
||||
|
|
|
Loading…
Reference in New Issue
Block a user