-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
When uploading, automatically reduce the size of receipt image #45448
When uploading, automatically reduce the size of receipt image #45448
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] |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or do you want to manipulate this condition?
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.
@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. |
@shubham1206agra I'm investigating to find a fix for this case. |
@shubham1206agra The context is here. Because the canvas area limit on IOS Safari is
cc @luacmartins |
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 |
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.
LGTM
✋ 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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