Sample code for 30+ languages & platforms
Xbase++

Extract data:image/png;base64 from HTML

See more Base64 Examples

Demonstrates how to extract base64 image data from HTMl and save to files.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oSb
LOCAL oBd
LOCAL oSbFilename
LOCAL nIndex
LOCAL nMayHaveMore
LOCAL cSBase64
LOCAL nCount

nSuccess := 0

oSb := CreateObject("Chilkat.StringBuilder")
oBd := CreateObject("Chilkat.BinData")
oSbFilename := CreateObject("Chilkat.StringBuilder")
nIndex := 1

nSuccess := oSb:LoadFile("qa_data/html/oresp body.txt", "utf-8")
//  Assume success.
? "length = " + Str(oSb:Length)

nMayHaveMore := 1
DO WHILE nMayHaveMore == 1

    //  Get the base64 between the 1st occurrence "data:image/png;base64," and "'"
    cSBase64 := oSb:GetBetween("data:image/png;base64,", "'")

    //  If nothing is found, then we'll exit the loop because there are no more.
    nMayHaveMore := oSb:LastMethodSuccess

    IF (oSb:LastMethodSuccess == 1)
        //  Found something.
        //  Load into bd and save.
        nSuccess := oBd:LoadEncoded(cSBase64, "base64")

        oSbFilename:SetString("qa_output/png_")
        oSbFilename:AppendInt(nIndex)
        oSbFilename:Append(".png")

        oBd:WriteFile(oSbFilename:GetAsString())

        //  Replace "data:image/png;base64" with "data:image-png;base64" so the next iteration finds the next occurrence.
        oSb:ReplaceFirst("data:image/png;base64", "data:image-png;base64")
    ENDIF

    nIndex := nIndex + 1
ENDDO

//  Restore our replacements..
nCount := oSb:Replace("data:image-png;base64", "data:image/png;base64")

? "All done."

oSb:destroy()
oBd:destroy()
oSbFilename:destroy()