-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[mob][photos] resize widget images to 1024px #7649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mob][photos] resize widget images to 1024px #7649
Conversation
Co-authored-by: Codex <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Future<Map<String, dynamic>?> _processWidgetImage( | ||
| Map<String, dynamic> param, | ||
| ) async { | ||
| final Uint8List bytes = param['bytes'] as Uint8List; | ||
| final int targetSize = param['targetSize'] as int; | ||
|
|
||
| final img.Image? decoded = img.decodeImage(bytes); | ||
| if (decoded == null) { | ||
| return null; | ||
| } | ||
|
|
||
| final int originalWidth = decoded.width; | ||
| final int originalHeight = decoded.height; | ||
| final int minSide = math.min(originalWidth, originalHeight); | ||
| if (minSide <= 0) { | ||
| return null; | ||
| } | ||
|
|
||
| img.Image working = decoded; | ||
| bool croppedToSquare = false; | ||
| if (originalWidth != originalHeight) { | ||
| final int cropSize = minSide; | ||
| final int left = ((originalWidth - cropSize) / 2).round(); | ||
| final int top = ((originalHeight - cropSize) / 2).round(); | ||
| working = img.copyCrop( | ||
| decoded, | ||
| x: math.max(0, left), | ||
| y: math.max(0, top), | ||
| width: cropSize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle EXIF orientation before cropping widget images
The new PNG generation path decodes bytes with img.decodeImage and immediately crops/resizes the raw buffer, but the image package does not apply EXIF orientation. Portrait photos whose rotation is stored in metadata will therefore be written sideways and cropped from the wrong edge. The previous implementation rendered via Flutter codecs, which respect EXIF, so this is a regression that will misalign a large fraction of camera images. Consider baking orientation (e.g. img.bakeOrientation) or decoding with a codec that honors EXIF before cropping.
Useful? React with 👍 / 👎.
Co-authored-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>
|
@codex review |
Co-authored-by: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { | ||
| final File? downloaded = await downloadAndDecrypt(file); | ||
| if (downloaded != null && await downloaded.exists()) { | ||
| final Uint8List bytes = await downloaded.readAsBytes(); | ||
| if (bytes.isNotEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remote widget images bypass cache and redownload each update
The new V2 code now fetches remote images via downloadAndDecrypt and later deletes the returned file in _WidgetSourceBytes.dispose. The previous implementation called getFileFromServer, which stores decrypted files in the cache manager so subsequent widget syncs can reuse them. With this change, every widget refresh will download and decrypt the same photo again, even when it was already fetched, which unnecessarily increases network traffic and battery usage for widgets that sync periodically. Reusing getFileFromServer or persisting the downloaded file would keep the caching behavior.
Useful? React with 👍 / 👎.
- Fix caching: use getFileFromServer instead of downloadAndDecrypt - Add file size check (50MB limit) before downloading remote files - Track failed render attempts to avoid retry loops on bad files - Add try-catch around image processing to handle malformed images/OOM - Show dimensions and source label for internal users with TODO - Remove duplicate home_widget import and fix type reference Co-authored-by: Claude <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
As discussed, let's keep the logic to render within home_page.dart only |
Description
Use 1024px for widgets
Tests