Skip to content

Instantly share code, notes, and snippets.

@alxsimo
Created March 15, 2016 11:40
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alxsimo/60b195ba4ac761a5d922 to your computer and use it in GitHub Desktop.
Save alxsimo/60b195ba4ac761a5d922 to your computer and use it in GitHub Desktop.
[Android] Convert image to bytes[] array with Glide
public static byte[] generateByteArrayProfileImage(Context context, Uri uri)
throws ExecutionException, InterruptedException {
int width = Constantes.PROFILE_IMAGE_SIZE_WIDTH;
int height = Constantes.PROFILE_IMAGE_SIZE_HEIGHT;
return Glide.with(context.getApplicationContext())
.load(uri)
.asBitmap()
.toBytes(Bitmap.CompressFormat.JPEG, 70)
.centerCrop()
.into(width, height)
.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment