code: public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int size,
                                      final int borderWidth, @ColorInt final int borderColor) {
          Condition.INSTANCE.ensureAtLeast(borderWidth, 0, "The border width must be at least 0");
          Bitmap clippedBitmap = clipSquare(bitmap, size);
          Bitmap result = Bitmap.createBitmap(clippedBitmap.getWidth(), clippedBitmap.getHeight(),
                  Bitmap.Config.ARGB_8888);
          Canvas canvas = new Canvas(result);
          float offset = borderWidth / 2.0f;
          Rect src = new Rect(0, 0, clippedBitmap.getWidth(), clippedBitmap.getHeight());
          RectF dst =
                  new RectF(offset, offset, result.getWidth() - offset, result.getHeight() - offset);
          canvas.drawBitmap(clippedBitmap, src, dst, null);
  
          if (borderWidth > 0 && Color.alpha(borderColor) != 0) {
              Paint paint = new Paint();
              paint.setFilterBitmap(false);
              paint.setStyle(Paint.Style.STROKE);
              paint.setStrokeWidth(borderWidth);
              paint.setColor(borderColor);
              offset = borderWidth / 2.0f;
              RectF bounds = new RectF(offset, offset, result.getWidth() - offset,
                      result.getWidth() - offset);
              canvas.drawRect(bounds, paint);
          }
  
          return result;
      }
docs: Clips the long edge of a bitmap, if its width and height are not equal, in order to transform
  it into a square. Additionally, the bitmap is resized to a specific size and a border will be
  added.
  
  @param bitmap
  The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The
  bitmap may not be null
  @param size
  The size, the bitmap should be resized to, as an {@link Integer} value in pixels. The
  size must be at least 1
  @param borderWidth
  The width of the border as an {@link Integer} value in pixels. The width must be at
  least 0
  @param borderColor
  The color of the border as an {@link Integer} value
  @return The clipped bitmap as an instance of the class {@link Bitmap}