Skip to main content
Participating Frequently
October 4, 2006
Question

Export to PNG from Illustrator

  • October 4, 2006
  • 26 replies
  • 21118 views
Does anyone have the AIPNGFormatAction.h header file so I can export Illustrator to PNG. I have found the AIPDFFormatAction.h header and got it working but I need the parameters for setting the resolution of the PNG.
This topic has been closed for replies.

26 replies

Toto RoToTO
Inspiring
June 24, 2008
thanks for giving me key name. :)
I didn't assume the fact that keys were in decimal.

ps: we could also use the Rasterize suite, and then export the result.
Toto RoToTO
Inspiring
June 24, 2008
Exaclty, I forgot to explain the fact that Art must be selected before rasterizing and exporting it. This stuff is done is elsewhere in my code.

A helper class does this stuff.

Here it is how I do. (It works, but I do not tell that is the way it should be done ;) )

first: I insert a temp layer in the Artwork tree.
then : duplicate art you want to be exported and add it to tempLayer, and set its selection state. (See Art suite and setUserAttributes.)
after: hide all others layers
and finally: call commands, dispose duplicated art and delete temp layer.
roll back to previous state for all layers.

Thomas.
Toto RoToTO
Inspiring
June 24, 2008
Participating Frequently
June 24, 2008
I have tried your code and the

result1 = sAIActionManager->PlayActionEvent("ai_plugin_rasterize", dialogStatus1, valueParameterBlock1);

does not seem to work unless you select all before the call.

result1 = sAIActionManager->PlayActionEvent(kAISelectAllAction, kDialogOff, NULL);

Any ideas? The ai_plugin_rasterize module says that there is an invalid selection in the PlayActionEvent call.
Participating Frequently
June 24, 2008
This is just the code I was originally looking for. Thank you for sharing this with us. To clean up your code a bit I have converted your numbers into hex and then into characters so it is more readable. So 1668246642 = 0x636F6C72 = 'colr' as 0x63 is the ASCII code for a 'c', 0x6F = 'o', 0x6C = 'l' and 0x72 = 'r'. Here are the rest:

1668246642 = 0x636F6C72 = 'colr'
1685088558 = 0x6470692E = 'dpi.'
1651205988 = 0x626B6764 = 'bkgd'
1954115685 = 0x74797065 = 'type'
1634494763 = 0x616C692B = 'ali+'
1835103083 = 0x6D61736B = 'mask'
1885430884 = 0x70616464 = 'padd'

Also "Lissage" means "Smoothing" or "Anti-alias" in English.

Thank you again. I will give it a try.

Robin Landsbert
Toto RoToTO
Inspiring
June 24, 2008
For information I find a workaround to export art as png, using 'ai_plugin_rasterize' and 'adobe_exportDocument' commands.

First of all, art is rasterized using 'ai_plugin_rasterize' command.
I used action scripts, as you told me, to 'hack' adobe' command. Command is used as follow:

ASErr result1;
AIActionParamValueRef valueParameterBlock1 = NULL;
ActionDialogStatus dialogStatus1 = kDialogOff;

result1 = sAIActionManager->AINewActionParamValue(&valueParameterBlock1);
if (valueParameterBlock1)
{
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1668246642, "CMJN");
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1685088558, "72");
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1651205988, "1");
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1954115685, "0");
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1634494763, "1");
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1835103083, "0");
result1 = sAIActionManager->AIActionSetString(valueParameterBlock1, 1885430884, "0.0");

result1 = sAIActionManager->PlayActionEvent("ai_plugin_rasterize", dialogStatus1, valueParameterBlock1);
result1 = sAIActionManager->AIDeleteActionParamValue(valueParameterBlock1);
}

This is hardcore and awful coding! ;) all keys are cuted and pasted directly from action script I have made, and values iare directly written in that method.

Parameter 1 : Color Model. (enumerated)
Parameter 2 : Resolution. (integer)
Parameter 3 : Background (enumerated)
Parameter 4 : (enumerated)
Parameter 5 : Do not know the correct translation in English, "Lissage" mode in french in the text. (enumerated)
Parameter 6: Create a mask (boolean)
Parameter 7 : add point around art.(unit real)

Then adobe_exportDocument is called.
As it shown above, command is called like that:

ASErr result;
AIActionParamValueRef valueParameterBlock = NULL;
ActionDialogStatus dialogStatus = kDialogOff;

result = AIActionManager->AINewActionParamValue(&valueParameterBlock);

if (valueParameterBlock)
{

result = sAIActionManager->AIActionSetString(valueParameterBlock, 'name', pathName);

result = sAIActionManager->AIActionSetString(valueParameterBlock, 'frmt', "Adobe PNG Format");

result = sAIActionManager->AIActionSetString(valueParameterBlock, 'extn', "png");

result = sAIActionManager->PlayActionEvent("adobe_exportDocument", dialogStatus, valueParameterBlock);

result = sAIActionManager->AIDeleteActionParamValue(valueParameterBlock);
}
A. Patterson
Inspiring
June 11, 2008
I hope it works out -- if there's anything I've learned from getting to know this API is that there is a *ton* of great stuff in there, but for some reason a lot of it is named about as unintuitively as you could imagine! :)
Participating Frequently
June 11, 2008
Great. Glad that it has been useful to both of us. And thanks again A. Patterson for the pointer to the header file.
Toto RoToTO
Inspiring
June 11, 2008
Thanks! It'is exactly what i was looking for! :)
Participating Frequently
June 11, 2008
AIImageOptimization.h looks much more promising. The AIImageOptPNGParams has the parameters for resolution and alpha and even width and height so this should be perfect. Thank you again for the pointer.