Search code examples
imageweb-servicesbinarybase64freemarker

How to convert a jpg image to base64 with freemarker


I am looking for a way to send a link to an image such as

imageLink

and converting the base64 binary to a string. It doesn't matter if it's via a function in freemarker or via a Webservice. How can I do this?


Solution

  • Have the solution, just written a php-script:

    <?php
        header('Content-type: application/json; charset=utf-8');
        $link   = $_GET['link'];
    
        $imagedata = file_get_contents($link);
    
        // alternatively specify an URL, if PHP settings allow
        $base64 = base64_encode($imagedata);
    
        print($base64);
    ?>