Skip to content
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

ImageQuality API differ on IOS and Android: Use one scale for both #5474

Closed
madmas opened this issue Feb 27, 2018 · 7 comments · Fixed by #5517
Closed

ImageQuality API differ on IOS and Android: Use one scale for both #5474

madmas opened this issue Feb 27, 2018 · 7 comments · Fixed by #5517

Comments

@madmas
Copy link
Contributor

madmas commented Feb 27, 2018

On IOS, Image-Source expects a number between 0.0 to 1.0 to specify the image quality.
On Android, Image-Source expects a number netween 0 and 100.

It brings up the situation developers have to use a platform-check if the want to get a JPG with 80% quality:

   let quality = platformModule.isAndroid ? 80 : 0.8;
   return image.toBase64String("jpeg", quality);

I'd suggest to use one scale for both platforms to have an more consistent API.
What do you think?

@NickIliev
Copy link
Contributor

@madmas sounds legit - I am marking this issue as a "good first issue" so that anyone interested in becoming a NativeScript contributor can make a PR and implement this one.

I am guessing one possible approach would be to change the iOS implementation of toBase64String where the quality is passed to getImagedata which works with the native values (0.0 to 1.0). So a potential fix would be to normalize the value before passing it to getImageData (e,g, in 'toBase64Striing' receive 80 as quality and pass 0.8 to getImageData)

Once this is done we could implement this for saveToFile as well.

@sudhanshu-15
Copy link
Contributor

@NickIliev I will like to work on this issue. Any guidance will be really helpful.

@sudhanshu-15
Copy link
Contributor

@NickIliev Need some help, I followed the Initial Setup and tried to run the Unit tests but every time I am getting this error:

Unable to apply changes on device: ZX1G4247XN. Error is: cp: no such file or directory:/Users/sudhanshu/Documents/Projects/NativeScript/tests/node_modules/tns-android/framework/libs.

I am really interested in getting this done, any help will be appreciated.

@sudhanshu-15
Copy link
Contributor

Update: I was able to fix the issue. I made the required code changes, I also added few extra unit tests. Most test cases are passing but there is one test case with LABEL module that is falling.
LABEL.test_Set_TextWrap_Native

Also I have been getting these these errors:
W ExifInterface: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)

image

I am still trying to figure out how to fix these, google search also didn't yield any useful information.
If anyone can help me out I will really appreciate it.

@sudhanshu-15
Copy link
Contributor

Update: I ran the tests on another device and now all the tests are passing. Still getting these errors:
W ExifInterface: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)

sudhanshu-15 added a commit to sudhanshu-15/NativeScript that referenced this issue Mar 9, 2018
… both platforms

Normalize quality in saveToFile and toBase64String to follow 0-100 scale - standardize implementation on both platforms

closes NativeScript#5474
@ghost ghost added the ♥ community PR label Mar 9, 2018
@sudhanshu-15
Copy link
Contributor

Submitted PR #5517

@NickIliev NickIliev added this to the 4.0 milestone Mar 12, 2018
sudhanshu-15 added a commit to sudhanshu-15/NativeScript that referenced this issue Mar 13, 2018
… both platforms

Normalize quality in saveToFile and toBase64String to follow 0-100 scale - standardize implementation on both platforms

closes NativeScript#5474
sudhanshu-15 added a commit to sudhanshu-15/NativeScript that referenced this issue Mar 13, 2018
…rces

update definitions and fix logic of quality in image-sources

closes NativeScript#5474
@vakrilov vakrilov removed the backlog label Mar 13, 2018
vakrilov pushed a commit that referenced this issue Mar 13, 2018
)

* feat(ios-image-source): standardize quality scale in image-source for both platforms

Normalize quality in saveToFile and toBase64String to follow 0-100 scale - standardize implementation on both platforms

closes #5474
@lock
Copy link

lock bot commented Aug 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants