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
feat: add different resize modes and onlyScaleDown options #233
Conversation
6b4f59b
to
5f34733
Compare
@PierreCapo I just updated the code to be rebased on the latest master and conflict-free! Let me know if you might be able to take a look here; I'd really appreciate it 😀 |
Hello @pxpeterxu sorry I'm super sad for not having reviewed this pr sooner. And honestly it's a pretty astonishing PR, thank you so much for having taken thee time to open it. I'll try to review it and make a release this week |
Hey, no worries @PierreCapo! Thanks for writing a great library in the first place; it works a lot better than |
This is a good PR! |
@PierreCapo - is there any chance of getting this merged still? Let me know! Happy to do a review of my own too. I'm using a patch of this PR in the meantime |
@hsource I forgot about this PR, but yes please I'd need some help to review this PR. I didn't write this lib, I'm just managing it and my knowledges in Java are not great. I'm better in Objective-C but I'd need some help there too. By the way, I think with this big PR merged, we could start migrating from Obj-C to Swift without losing too much work in progress, since at bam we are mostly using Swift (in which I'm far more comfortable with too). @cristianoccazinsp I know you are pretty familiar with the codebase, if you got time, could you help reviewing this PR too please? @hsource did you face any issue while using the fork? Waiting for your green lights guys |
@PierreCapo - heads up, the fork has been running well on our app for the past few months. I totally forgot about this until now, so sorry for the delay! I ran the example app and looked through the code, and honestly this looks like a really great change. I recommend just pulling this! |
I've tested and I've found nothing wrong on my side too 👍 Merged and release under Have a good day! |
Lovely PR! I will be giving a try within the following days (I also forgot about it for a long time :() and will provide feedback if anything breaks. Our app heavily depends on image processing so I think it will be a good test. |
@PierreCapo @pxpeterxu I was just trying this update. Looks like after upgrading to 1.4.0, all my image resizing are suddenly not preserving aspect ratio on Android and iOS. The update was a breaking one for our app. The following shows the before and after without any code changes (just a lib update). Looks like the defaults are not appropriate to preserve the previous behaviour: Also, I'm sorry I didn't test it earlier, could have caught this before the release if I did :( |
@cristianoccazinsp I can take a look at this! Which mode were you using (stretch, cover, contain), and was it an upsize or downsize? |
@pxpeterxu I did not set any mode at all, just default options. I was expecting the updates to be non-breaking. |
Any luck reviewing this? The update has been live for some time now and there was also another report about the issue here: #265 |
Motivation
I was resizing images for a Tensorflow model, which required images to be exactly 224x224, rather than some size smaller than 224.
Changes
options.mode
option tocreateResizedImage
with similar values to those for react-native 's resizeModecontain
: existing behavior: will resize image to be fit withinwidth
/height
, preserving the aspect ratiocover
: resize image to have one dimension bewidth
/height
, and the other be bigger, preserving the aspect ratiostretch
: will resize to exactly the width/height given, ignoring the aspect ratiooptions.onlyScaleDown
for cases where we only want the resulting image to be smaller or the same size as the originalTesting
Tested using an actual Android device (Pixel 3a, Android 10) and iOS Simulator (iPhone 8, iOS 13.3)
Android
iOS