-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Summary
When validating large GIFs, validate_gif and is_slack_ready currently only enforce dimension limits. Files >5MB are noted in the output, but this does not affect the final passes result, and is much above the Slack guidance of max 128kb.
I suggest either
- Pass with warning at >128kb
- Fail at >128kb
Happy to send a tiny PR if that's helpful!
Reproduction
Steps to reproduce
- Create a 128x128 animated GIF with many frames so the file is several MB.
(in my case: 400 frames @ 50 fps, 128x128, size ~6.95 MB) - Run:
from core.validators import validate_gif, is_slack_ready passes, info = validate_gif("hello_shake_huge.gif", is_emoji=True, verbose=True) print("passes:", passes) print("slack_ready:", is_slack_ready("hello_shake_huge.gif", is_emoji=True))
Observed
Console output (abridged):
Validating hello_shake_huge.gif:
Dimensions: 128x128 (optimal)
Size: 7120.4 KB (6.95 MB)
Frames: 400 @ 50.0 fps (8.0s)
Note: Large file size - consider fewer frames/colors
Validation Result: ✅ PASSES
...
Slack Ready: Yes - Ready to upload!
So validate_gif returns passes = True, and is_slack_ready also returns
True, even though the file is ~7MB.
Expected
Either
- Warn at lower threshold
- Large files should fail validation
Suggestion: 128kb per Slack's docs.
Note: Slack says 'If your image is too large, we’ll try to resize it for you.', but even a 1.3MB version I created failed to upload.
Diagnosis and recommendation
Likely cause
Looking at core/validators.py:
- validate_gif calculates dim_pass from validate_dimensions.
- File size is checked only to print a “Note: Large file size…” message.
- The final passes value only uses the dimension result, not size.
- is_slack_ready simply wraps validate_gif and returns passes.
So file size never participates in the boolean success/fail, even when
is_emoji=True.
Possible fix
- Simpler: update the warnings
- Warn at >128kb with descriptive message, for example:
Warning: File size >128kb Slack guideline - consider fewer frames/colors
- Stricter: have validate_gif combine both dimension and size checks into passes.
- For example (pseudocode):
and have is_slack_ready(path, is_emoji=True) return that combined passes.
dim_pass, dim_info = validate_dimensions(width, height, is_emoji=is_emoji) size_pass, size_info = check_slack_size(path, is_emoji=is_emoji) passes = dim_pass and size_pass info = {"dimensions": dim_info, "size": size_info}