Yes
Yes
One Plus 6.
Using 'com.wonderkiln:camerakit:0.13.2'
(Write your steps here:)
My code:
@Override
public void onImage(CameraKitImage cameraKitImage) {
JpegTransformer jpegTransformer = new JpegTransformer(cameraKitImage.getJpeg());
byte[] bytes = new byte[1];
Rect cropBox;
Log.i(TAG, "The width of the captured image prior cropping is " + jpegTransformer.getWidth());
Log.i(TAG, "The height of the captured image prior cropping is " + jpegTransformer.getHeight());
Bitmap bitmap;
if (jpegTransformer.getWidth() < jpegTransformer.getHeight()) {
//Portrait
cropBox = new Rect(40, 331, 40, 331);
jpegTransformer.crop(cropBox);
Log.i(TAG, "The width of the captured image after cropping is " + jpegTransformer.getWidth());
Log.i(TAG, "The height of the captured image after cropping is " + jpegTransformer.getHeight());
bytes = jpegTransformer.getJpeg();
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
//bitmap = Bitmap.createScaledBitmap(bitmap, portraitWidth, landscapeWidth, true);
} else {
//Landscape
cropBox = new Rect(331, 40, 331, 40);
jpegTransformer.crop(cropBox);
Log.i(TAG, "The width of the captured image after cropping is " + jpegTransformer.getWidth());
Log.i(TAG, "The height of the captured image after cropping is " + jpegTransformer.getHeight());
bytes = jpegTransformer.getJpeg();
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
//bitmap = Bitmap.createScaledBitmap(bitmap, landscapeWidth, portraitWidth, true);
}
Log.i(TAG, "The width of the captured image from Bitmap after cropping is " + bitmap.getWidth());
Log.i(TAG, "The height of the captured image from Bitmap after cropping is " + bitmap.getHeight());
I expected the logged height and width to change
The height and width did not change :(
I have pasted my code above
Minor tweak to the code so that it's easier to copy + paste
@override
public void onImage(CameraKitImage cameraKitImage) {
JpegTransformer jpegTransformer = new JpegTransformer(cameraKitImage.getJpeg());
byte[] bytes = new byte[1];
Rect cropBox;
Log.i("+cam", "The width of the captured image prior cropping is " + jpegTransformer.getWidth());
Log.i("+cam", "The height of the captured image prior cropping is " + jpegTransformer.getHeight());
Bitmap bitmap;
if (jpegTransformer.getWidth() < jpegTransformer.getHeight()) {
//Portrait
cropBox = new Rect(40, 331, 40, 331);
jpegTransformer.crop(cropBox);
Log.i("+cam", "The width of the captured image after cropping is " + jpegTransformer.getWidth());
Log.i("+cam", "The height of the captured image after cropping is " + jpegTransformer.getHeight());
bytes = jpegTransformer.getJpeg();
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
//bitmap = Bitmap.createScaledBitmap(bitmap, portraitWidth, landscapeWidth, true);
} else {
//Landscape
cropBox = new Rect(331, 40, 331, 40);
jpegTransformer.crop(cropBox);
Log.i("+cam", "The width of the captured image after cropping is " + jpegTransformer.getWidth());
Log.i("+cam", "The height of the captured image after cropping is " + jpegTransformer.getHeight());
bytes = jpegTransformer.getJpeg();
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
//bitmap = Bitmap.createScaledBitmap(bitmap, landscapeWidth, portraitWidth, true);
}
Log.i("+cam", "The width of the captured image from Bitmap after cropping is " + bitmap.getWidth());
Log.i("+cam", "The height of the captured image from Bitmap after cropping is " + bitmap.getHeight());
}
Example project attached in case anyone else wants to try to repro! I was able to reproduce this issue as well.
Thanks for sharing this Corey. I will take a look at this and come back to
you with what I find. To make it work on One Plus 6 phone here is the
combination of thigs that failed and worked:
1) com.camerakit:camerakit:1.0.0-beta3.1 does not show a camera preview so
failed
2) com.wonderkiln.camerakit:0.13.2 worked mostly well but had two issues in
my limited requirement:
a) in landscape view, after a click the preview used to get distorted
b) The crop did not work as stated at the beginning of this ticket
The workarounds I have made which solved it for me (and this might be
specific to OP6 only) - for solving (a) I downgraded to
com.wonderkiln.camerakit:0.13.0
and for solving (b) I replaced the com.wonderkiln.JpegTrasformer with
jpegkit.JpegTransformer
.
So now the above might just be a group of workarounds but it does the job
for me today when I ran out of time to wait for the perfect 1.0.0 to come
up...
On Sat, Aug 11, 2018 at 6:17 AM, Corey Johnson notifications@github.com
wrote:
Example project attached in case anyone else wants to try to repro! I was
able to reproduce this issue as well.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://mailtrack.io/trace/link/bbff41f94522603b9fec9c10fcf2e92cc0fd9f23?url=https%3A%2F%2Fgithub.com%2FCameraKit%2Fcamerakit-android%2Fissues%2F398%23issuecomment-412238750&userId=2291577&signature=c89626f94ca4a7fb,
or mute the thread
https://mailtrack.io/trace/link/e77b7d2e3e74444b1016b8dc8b4ceaaf05bb02d6?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAj37S7_HxQtKZFHXZBJUh5kx3zyWKIFeks5uPimOgaJpZM4VyC-o&userId=2291577&signature=74890ed1a08108dc
.
Hey @pinigtech we've recently updated JpegKit to version v0.2.2. Try to crop again with the updated version. We recommend you use Jpeg to crop rather than JpegTransformer.
Closing this issue. If the problem persists I will reopen. Thanks!
Most helpful comment
Minor tweak to the code so that it's easier to copy + paste