Description
Checklist
- I am reporting an issue in existing functionality that does not work as intended
- I've searched for existing GitHub issues
Description
Images inserted into Telegram via clipboard (paste) or drag-and-drop behave differently compared to images attached from the gallery. Specifically:
-
Clipboard/Drag-and-Drop:
When an image is inserted via clipboard or drag-and-drop, it is forcibly resized before cropping to a maximum dimension of 1280px on the larger side, regardless of settings. -
Gallery Attachment:
When an image is attached from the gallery, the resizing occurs after cropping, resulting in better quality:- The cropped image is resized to 1280px on the larger side (no additional options for larger sizes in the original Telegram app).
This discrepancy leads to quality issues, particularly with screenshots.
Steps to Reproduce
- Take a screenshot and insert it into Telegram:
- Either via drag-and-drop or paste from the clipboard.
- Alternatively, attach the same screenshot via the gallery.
- Crop a small fragment of the image within the app.
- Compare the output quality and sharpness for each method.
Expected Behavior
- The resizing behavior should be consistent regardless of how the image is inserted.
- Resizing should occur after cropping, ensuring higher image quality and preventing unnecessary degradation.
Actual Behavior
- When inserting via clipboard or drag-and-drop:
- The image is resized to 1280px before cropping, leading to blurred or low-quality results for cropped fragments (especially due to non-integer scaling).
- When attaching via the gallery:
- The image is resized correctly after cropping, preserving quality even for smaller fragments.
Impact
- This inconsistency significantly affects the quality of cropped screenshots.
- For example, dragging a screenshot into Telegram and cropping a small fragment results in noticeable blurriness due to resizing being applied twice.
Suggested Fix
- Align the resizing logic for clipboard and drag-and-drop inputs with that of gallery attachments:
- Perform resizing only after cropping.
- Maintain the current behavior of resizing to 1280px on the larger side after cropping.
Environment
- Telegram version: 11.7.0 30143 beta build, also reproducible on previous builds, incl. stable branch
- iOS: iOS 18.2.1 (22C161)
- Device: iPhone 13
Additional Notes
This issue is especially noticeable when working with screenshots, as they often require precise cropping and resizing. The current behavior introduces unnecessary quality loss, which could be avoided with unified resizing logic.