I know we can use imagecreatefrompng and imagejpeg functions to convert PNG to JPEG. But it creates a new file.
I just need file_get_contents() to store the file into database. That means I need JPEG file contents from my PNG file
eg:-
imagejpeg(imagecreatefrompng($_REQUEST['sig_data']), "test.jpeg");
$appSig = addslashes(file_get_contents("test.jpeg"));
Above example I need to create a ‘test.jpeg’ file. If I didn’t pass that as an argument to imagejpeg function, it print the file in screen. And I can’t do object buffering also. imagejpg function just return the status.
Admittedly somewhat hacky, but you can capture the direct output of
imagejpeg: