0

I'm trying to crop an image when building a notification received by the server. At this moment I only have the image url.

Here's what I've tried:

Coil.load(context, remoteMessage.getImageUrl()) {
        target { image ->
            transformations(CircleCropTransformation())
            val person = Person.Builder()
                .setName(remoteMessage.getTitle())
                .setIcon(IconCompat.createWithBitmap(image.toBitmap()))
                .build()
         ...

It loads the image but doesn't crop it.

douglas.iacovelli
  • 900
  • 1
  • 9
  • 11

1 Answers1

0

Oops, I've just found out the issue. CircleCropTransformation() should be applied outside of the target block, such as:

Coil.load(context, remoteMessage.getImageUrl()) {
    transformations(CircleCropTransformation())
    target { image ->
        val person = Person.Builder()
            .setName(remoteMessage.getTitle())
            .setIcon(IconCompat.createWithBitmap(image.toBitmap()))
            .build()

The strange thing is: it does work for circleCropTransformation but it seems not to work when using a RoundedCornersTransformation

douglas.iacovelli
  • 900
  • 1
  • 9
  • 11