Encoding JPG file From SD card Using Base64 in Arduino

Hey dears, I am totally new to Arduino and I want to encode image file read from SD card using Base64 library. I am searching for exactly this thing for a month, but I am totally failed here. The scenario of my problem is that " I have a picture of format jpg in SD card, and I want to read that image from SD card and encode it using Base64. Here is another post where a friend had the same problem, but I didn't get his/her solution. https://forum.arduino.cc/index.php?topic=494929.0

The post does provide some links and explains what needs to be done . You can also google base 64 for basic info.

As the post says - image handling is not the best move with an Arduino due to memory constraints - why do you want to do it ? Therein may lie other solutions !

Thank you so much for the response. In fact, I want to send the encoded picture through gsm and I know how to do that. Right now, I need to encode the picture from SD card. Giving me a clue/code to encode the image/picture will be enough for the problem I am facing right now.

There are some google hits for sending pictures via GSM.

EG https://www.quora.com/Is-it-possible-to-send-an-image-captured-by-Arduino-camera-to-an-Android-phone-via-GSM-module

Thank you so much, Hammy, But I am not talking about sending or something. What I need to encode the stored photo in SD card using Base64 library. Sending it and making a photo of it is an easy job for me. My question is how to encode a picture using Base64 library. This is a library available for Arduino.

First, learn to use the base64 library by trying out the simple examples that come with it.

Come back if you have questions, being sure to tell us which library, where you downloaded it, and to post the code using code tags.

Yes, I have tried example given in the Library. Here is the github link from where I have downloaded the library. https://github.com/adamvr/arduino-base6

#include <Base64.h>

/*
 Base64 Encode/Decode example
 
 Encodes the text "Hello world" to "SGVsbG8gd29ybGQA" and decodes "Zm9vYmFy" to "foobar"

 Created 29 April 2015
 by Nathan Friedly - http://nfriedly.com/
 
 This example code is in the public domain.

 */


void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  Serial.println("Base64 example");
  
  
  
  // encoding
  char input[] = "Hello world";
  int inputLen = sizeof(input);
  
  int encodedLen = base64_enc_len(inputLen);
  char encoded[encodedLen];
  
  Serial.print(input); Serial.print(" = ");
  
  // note input is consumed in this step: it will be empty afterwards
  base64_encode(encoded, input, inputLen); 
  
  Serial.println(encoded);
  
  
  
  // decoding
  char input2[] = "Zm9vYmFy";
  int input2Len = sizeof(input2);
  
  int decodedLen = base64_dec_len(input2, input2Len);
  char decoded[decodedLen];
  
  base64_decode(decoded, input2, input2Len);
  
  Serial.print(input2); Serial.print(" = "); Serial.println(decoded);
}


void loop()
{
  
}

Do you have a question?

This library encodes text string! then how to encode the image stored on SD card?

A text string is just an array of bytes. A jpg file on SD card is just an array of bytes. Load a chunk of image; place it in an array of byte (aka char), encode, send out, repeat.