-
Notifications
You must be signed in to change notification settings - Fork 120
iOS - determine the output image type from the input image type #44
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
Conversation
with the .jpg extension. The previous RN ImageEditor stored the cropped image as a JPEG. This commit fixes this issue.
Fixes issue #43 |
@takameyer We have recently added support on iOS for cropping transparent images (PNG) just like it is done on Android. We should change the extension of the saved file to "png" from "jpg" instead of using |
If that is the case, then i require an extension so that it can be saved as jpeg. The old version worked this way and the app I am working on requires it. I will reword and rework the pull request. |
I guess the big question is what the default should be and how the interface should behave. In our app, we are taking direct camera input and providing an interface to crop the picture. JPEG behaves well in this case since it will never have a transparency. This is also what iOS expects, which is the problem with issue #35 . What I would like to see is: const format = ImageCropFormat.JPEG
const croppedImagePath = await ImageEditor.cropImage(uri, cropData, format) and ImageCropFormat would be defined as: enum ImageCropFormat {
JPEG = 'JPEG',
PNG = 'PNG'
} Since the old core library for ImageEditor used JPEG, I would set this as default. |
@takameyer I am ok with having an optional format argument that defaults to "jpeg". We just need to make sure Android behaves in the same way. Feel free to submit a PR that implements it. Thanks! |
the mimetype of the input image path and determines what it should save it as. If image/png is detected, then it will output a PNG. If anything else is detected, then it uses JPEG.
I reviewed the Android code and found out that it determines the mimetype of the input image and produces saves the cropped image as the determined mimetype, or JPEG if it cannot be determined. |
@Trancever Are you okay with this pull request? It is a bit different than we discussed, but I feel it is the correct way to handle it. |
@takameyer Let me check it tomorrow :) |
@takameyer I've tested your changes and it doesn't work properly. How did you test your changes? |
I tested directly from camera and camera roll. |
@takameyer So it doesn't work for me when I test images taken from web. Can you check that? |
…d nil. This has been replaced with a simple file extension check on the input url. If a PNG is provided, then a PNG is returned. Otherwise JPEG is returned.
@Trancever So it seems that the method i was using to convert UIImage to NSData was not successful in any case. I have reverted to checking the input url for the file extension and creating a PNG if a PNG is provided. Otherwise JPEG is returned. |
@takameyer Awesome, I will test it tomorrow and if everything works properly I will merge it. |
Hey @Trancever can we merge this now please ? |
This pull request saves the cropped image as a JPEG in iOS, reflecting the behavior of the previous library.
Android also preforms the same function.