Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I convert the the base64 to image and saving it as jpg?$('#image').attr("src", "data:image/png;base64," + $.scriptcam.getFrameAsBase64());
I really need your help! please help
Posted

1 solution

1. Remove the part
"data:image/png;base64," from your base64 string.
2. call the base64_decode
string base64_decode ( string $data [, bool $strict = false ] )
3. data on png file.
4. Finally use the following function to convert from png to jpeg
PHP
function png2jpg($originalFile, $outputFile, $quality) {
    $image = imagecreatefrompng($originalFile);
    imagejpeg($image, $outputFile, $quality);
    imagedestroy($image);
}


Function above is copied exactly as it is from some other[^] site
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900