When uploading, automatically reduce the size of receipt image#45448
When uploading, automatically reduce the size of receipt image#45448luacmartins merged 16 commits intoExpensify:mainfrom
Conversation
|
@shubham1206agra Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
luacmartins
left a comment
There was a problem hiding this comment.
I haven't tested but code LGTM. Left a small suggestion to simplify the resizing code
Co-authored-by: Carlos Martins <luacmartins@gmail.com>
|
@nkdengineer Can you send me file to test this PR? |
|
@shubham1206agra I think any image over 2MB should do it |
|
@shubham1206agra bump for review |
| }); | ||
|
|
||
| const resizeImageIfNeeded = (file: FileObject) => { | ||
| if (!file || !Str.isImage(file.name ?? '') || (file?.size ?? 0) <= CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) { |
There was a problem hiding this comment.
@shubham1206agra I think any image over 2MB should do it
@luacmartins This is not true. I need 24MB file to check this flow. See this line.
There was a problem hiding this comment.
Or do you want to manipulate this condition?
There was a problem hiding this comment.
@shubham1206agra you can download the large image here
Co-authored-by: Shubham Agrawal <58412969+shubham1206agra@users.noreply.github.com>
Screen.Recording.2024-07-29.at.9.50.30.PM.mov@nkdengineer This is giving weird result here. |
|
I'm running an adhoc build since the attachment flow can be a bit weird on the simulator. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
|
@luacmartins Still not working. |
|
@luacmartins I just tested uploading large image on main directly, and it works just fine. @nkdengineer Can you please look into why this is happening? |
|
Checking this now. |
|
Asked in Slack for someone familiar with |
|
@luacmartins @nkdengineer It looks like enforcing the canvas size within the limits before performing the operations (on the image manipulator level) seems to be fixing the problem. It's a bit weird, because with those assumptions the canvas is smaller than the image being processed (for a brief moment), but the end result should be fulfilling our expectations. On the other hand, what should not be fulfilling our expectations is the processing time - I'd suggest at least adding the indicator that the image is being processed. Uploading images of that size is probably not a common case, but this might be slightly confusing. I'll try to send a PR during the week-end and discuss it in the image-manipulator repository directly, but for now that should be sufficient. If you don't have any concerns regarding this approach, I think we could include the forementioned patch in this PR. Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-08-01.at.16.34.09.mp4 |
|
Nice! Thanks for the investigation @BrtqKr! Looking forward to the PR! |
|
@nkdengineer if you could apply this, it would be amazing. Let me know if you have any problems related to this patch. If this gets merged before I discuss it with expo and the library gets released, I'll clean this patch and bump the version in a separate PR. |
|
@BrtqKr I will add the patch in this PR soon. |
|
@shubham1206agra Updated the patch for the resizing solution, I tested and it works well. Please help to test again, thanks. |
|
@nkdengineer Looks like you inserted the patch incorrectly. It has unnecessary info. |
|
@shubham1206agra I updated, I missed re-installing the lib before creating the patch. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeScreen.Recording.2024-07-29.at.10.08.02.PM.moviOS: NativeScreen.Recording.2024-07-29.at.10.20.50.PM.moviOS: mWeb SafariScreen.Recording.2024-08-05.at.3.43.00.PM.movMacOS: Chrome / SafariScreen.Recording.2024-07-29.at.9.42.34.PM.movMacOS: DesktopScreen.Recording.2024-07-29.at.10.11.34.PM.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.17-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.17-2 🚀
|
2 similar comments
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.17-2 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.17-2 🚀
|
Details
Fixed Issues
$ #44084
PROPOSAL: #44084 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
android-mweb.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios-mweb-resize.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov