M
M
Mnobody2014-04-09 22:28:48
PHP
Mnobody, 2014-04-09 22:28:48

Why doesn't PHP imagecreatefromstring() recognize string?

You need to get a picture from the site. The site returns it in the form of base64Binary (using the API of this site). A string
comes in, I decode it with $data = base64_decode($string); and I can display in the browser like this:

echo '<img src="data:image/jpeg;base64,'.$data.'">';

But this line gives an error:
$im = imagecreatefromstring($data);
Warning: imagecreatefromstring(): Data is not in a recognized format
The fact is that I need to edit this image later.
The site API uses NuSOAP. I didn't find anything specific on the Internet.
In which direction to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2014-04-09
@Mnobody

if it works for you

echo '<img src="data:image/jpeg;base64,'.$data.'">';

so your $data is still in base64.
try:
$im = imagecreatefromstring(base64_decode($data));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question