News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate's Blog:
Unpacking binary data in PHP
September 22, 2010 @ 10:45:52

Sameer Borate has a new post to his blog today talking about a method for unpacking binary data directly in PHP - specifically in working with images.

To set the stage we will start with a programming problem, this will keep the discussion anchored to a relevant context. The problem is this : We want to write a function that takes a image file as an argument and tells us whether the file is a GIF image; irrelevant with whatever the extension the file may have. We are not to use any GD library functions.

He shows how to use the unpack function to open up the file and pull out the raw data - including the header information that tells you what kind of file it is you're working with. There's also an example of unpacking the header contents and grabbing things like height, width and the aspect of the image.

0 comments voice your opinion now!
unpack binary data tutorial gif image


blog comments powered by Disqus

Similar Posts

Brandon Savage's Blog: Peer Review: You Have Not Because You Ask Not (Requests & Responses)

PHPMaster.com: Letís Talk: Efficient Communication for PHP and Android, Part 1

PHP/Cloudcast: Getting Started with Stripe Webhooks

DevShed: Defining a Model Class for Handling Views with CodeIgniter

Jakub Zalas' Blog: Mocking Symfony Container services in Behat scenarios with Mockery


Community Events

Don't see your event here?
Let us know!


video library podcast laravel5 interview wordpress series development language laravel api release community unittest framework opinion voicesoftheelephpant psr7 extension introduction

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework