esp32-cam encode image to base64

I am trying code from this tutorial ESP32-CAM Take Photo and Display in Web Server | Random Nerd Tutorials which works for me.

I want to slightly modify this so image get pushed to MQTT.
For this I trying to conver image into base64

.
.
#include <base64.h>
.
.
      String encoded = base64::encode(fb->buf);
      Serial.println(encoded);

For this I get compile error

esp32-cam-mqtt.ino: In function 'void capturePhotoSaveSpiffs()':
esp32-cam-mqtt:232:43: error: invalid user-defined conversion from 'uint8_t* {aka unsigned char*}' to 'const String&' [-fpermissive]
       String encoded = base64::encode(fb->buf);

This works fine

      String toEncode = "Hello World";
      String encoded = base64::encode(toEncode);
      Serial.println(encoded);

How do I get the image in a string format which I can convert to base64 ?

the base64 class has a method:

static String encode(const uint8_t * data, size_t length, bool doNewLines = true);

which you can pass in a buffer and its length.

From your code, you need to also pass in the length of your buffer as second argument.