Is there a way to turn a jpg to string, reverse of imagecreatefromstring?
I have to communicate to a server which needs binary of image, i saw plenty of jpg to binary but not the other way around.
Is there a way to turn a jpg to string, reverse of imagecreatefromstring ?
Share
imagecreatefromstringtakes a string which contains the binary data of an image and turns it into a gd image resource so you can manipulate it with the gd image library. Literally the “reverse” of that would beimagejpeg, which saves a gd image resource to a jpeg image.I guess what you really want though is simply the initial string, which contains the binary data of the image to begin with. I.e.:
$imageString = file_get_contents('image.jpg');$gd = imagecreatefromstring($imageString);Just skip step 2.