I want to get the stored resource fork. In PHP, I'm trying to:
system('DeRez' . $_icon . ' | perl -ne \'m|/\* (.*) \*/| && print $1; END {print "\n"}\', $content);
which in Terminal really returns the content of the icon. However, creating an image from it using imagecreatefromstring
returns an error.
So, there's a command-line voodoo that outputs the raw data of the resource fork (in my case, the folder icon)?
Best Answer
The icon encoded within the resource fork is not in a format PHP's imagecreatefromstring can understand.
PHP's
imagecreatefromstring
requires: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.