mrkeck Sharing the Love

9Mar/130

PHP HTML img src BLOB

echo "<img src='data:image/jpeg;base64, " . base64_encode(your BLOB) . "'>"
Filed under: HTML, PHP No Comments
7Mar/130

PHP Get Directory Above Web Root

dirname($_SERVER['DOCUMENT_ROOT'])
Filed under: PHP No Comments
4Mar/130

PHP GD jpg too large

This one had me stumped for a while. I am using WAMP, but has nothing to do with the issue.

I was trying to manipulate a jpg that was 1.3MB, which I was sure was not too large. However, that is the compressed size. Once it is loaded into GD it is no longer compressed. In order to calculate the uncompressed size, multiply the pixel width times pixel height times 4 (conversion rate from pixels to bytes)

(w x h x 4)

Make sure the memory_limit in php.ini is large enough to handle the load

Example

Assume sample jpg is 1.3MB and has width of 2,500 pixels and height of 5,000 pixels
(2500 x 5000 x 4)=50,000,000 (50MB)

Filed under: GD, PHP No Comments