tags:

views:

74

answers:

2

I am looking for php script that convert .png file to .icns file for mac.

Thanks.

+1  A: 

You can use imagemagick if available:

$im = new imagick( '/path/to/file.png' ); 


$im->setCompressionQuality(100);
$im->setImageFormat('icns');

$im->writeImage('/path/to/new/file.icns');
$im->clear();
$im->destroy();

Find out if you have imagemagick, with phpinfo

berkes
Thank you very much @berkes. Currently I don't have imagemagick installed.I am trying to install it but facing some problem. I am using xampp.
Mayur bhalgama
xampp comes with php_gd shipped, afaik. So you may be able to use that. The code will be very different from above, though.
berkes
@berkes I have tried above code but no success. Actually, imagick doesn't support "icns" format.
Mayur bhalgama
+1  A: 

Apparently imagemagick does not support icns out of the box (I am sure I used it before, but maybe with some additional library? Cannot remember)

However, just tested the little Linux too icnsutils. It does not have PHP-bindings, so you will need to issue a system call (the horror)

Be vary wary of using variables whom you cannot entirely trust, in system calls. :)

berkes
yes. My colleague already implemented this way. He used linux script (.sh file). I thought if there is php script to do this. Thanks again.
Mayur bhalgama