How to get the content of a Resource Fork?
The icon encoded within the resource fork is not in a format PHP's imagecreatefromstring can understand.

PHP's imagecreatefromstring requires:


JPEG
PNG
GIF
WBMP
GD2


Use sips

Investigate the Mac OS X command sips for working with icons on the command line. See Manipulate Mac OS X file icons from Automator or command-line for examples.

DeRez

The DeRez command will output the raw resource fork data. The manual for DeRez provides options for filtering the output data and requesting specific encoding; be aware that the encoding options are limited to how the hexadecimal is escaped. Rather than allowing for graphic format conversion.