not a pbm, pgm or ppm file. by ocrad : <p>I'm sending a book page photo from browser to PHP. I'm writing the photo to disk using this:</p>

<pre><code>$decoded = base64_decode($img);
file_put_contents($output_file, $decoded);
</code></pre>

<p>However when I run <a href="https://www.gnu.org/software/ocrad/" rel="nofollow noreferrer">ocrad</a>/<a href="http://jocr.sourceforge.net/" rel="nofollow noreferrer">gocr</a> for the image then <code>gocr</code> shows error </p>

<blockquote>
  <p>"bad magic bytes, expect 0x50 0x3[1-6] but got 0xff 0xd8"</p>
</blockquote>

<p>while <code>ocrad</code> says </p>

<blockquote>
  <p>"ocrad: bad magic number - not a pbm, pgm or ppm file."</p>
</blockquote>

<p>What could be the problem?</p>
