Export layers to JPG file
Hi,
I wants to export only a single layer as JPEG file in Automation plugin. I have gone through the the implementation in which every layers in the current document is exported as files. But i wants to export any particular layer. I had searched the API for this, but havent got a single may be i am very new to this.
Please guide me with what steps should i follow to achieve this.
Thanks a lot.
You _may_ actually be able to do what you want by using ActionScript without even going to the Automation plugin. I'd really explore this possibility first, since to do your task in C++ you'll have to write quite a substantial amount of code.
If you have to go though Automation, start with the Getter plugin from the SDK - it will provide you with the information about the layers within a document. The rest depends on how you'd like your plugin to work: if, for instance, you want a GUI with a layer selection functionality, you probably will have to write a bunch of functions that use the document descriptor to count the layers, retrieve their properties and then display them to the user with some third-party toolkit or native GUI API that will supply you back with the selected layer's ID or index. You may also simplify your task and always export the current layer, in which case you need no GUI / layer enumeration etc
I hope that provides you with enough info to start
Similar Messages
-
How to export layer in jpg files ?
Hi everyone,
I am trying to develop a plug-in for Ai CS4 in which I need to export all the layers in jpg files. Could any one tell me the API that can help me to do so ?
or any suggestion how I can do this.
thanks in advance.Well, the AIRasterizeSuite (AIRasterize.h) will have tools that let you convert sets of art into raster objects in Illustrator. And the AIArtSetSute (AIArtSet.h) has methods that let you construct said art sets from the contents of layers. From there, you'd have to take the contents of the generated raster objects and save them out manually to JPEG.
Oh, just found another that might be what you want. AIImageOptimization.h has methods like 'AsJPEG', which seem to take an art handle (which could be the group at the root of a layer from the sounds of it). So that would presumably let you do dump that to JPG. It uses AIDataFilters though, and I don't know how those work.
I think this has come up before in this forum, so if you do da little searching you might come across some better help than me. It's definitely doable though. -
How do I export Layers to individual Files?
In Photoshop CS, there is a script that exports Layers to individual Files.
Go to File>Scripts>Export Layers to Files.Hi Arien,
If your animation program supports paste open it and select each layer,
Select>All, Edit>Copy and paste that layer into that program.
If your animation program doesn't support paste you can paste each layer
into a New file and save it as a *.png image.
Alex ., -
Exporting Layers to individual files
Simple question. Is it possiple to export layers to indivual files in Photoshop elements 8?
This issue is driving up the wall. So far I have been unable to locate a singl, am I ,issing something?
discussion or tutorial on the subject.
Any input will be most appreciatedIf you have pse 6 through pse 10, then this export layers to files script should work:
https://acrobat.com/#d=blJVJ4ZFfR7dRg24q-mBbQ
To install:
1. download and unzip
2. right click on the script and choose copy
3. navigate to the elements scripts folder
example path: (windows and sustitute your version for 8.0)
C:\Program Files (x86)\Adobe\Photoshop Elements 8.0\Presets\Scripts
4. right click in a blank area and choose paste
5. start or restart elements and export layers to files should be listed under Files>Automation Tools -
Print module - exporting to a .jpg file - borderless printing
I'm attempting to export a picture as an 8 x 10 .jpg file in the Print Module - I want the image to be borderless. I have gone ahead and changed my page setup to reflect the same dimensions, I've removed margins and I've also gone into the Layout section and adjusted my cell size dimensions and removed margins...I can't seem to get two borders to disappear - if it's a portrait image, the sides have white borders and if it's landscape, the top and bottom have white borders.
Any help would be greatly appreciated. Thanks. If more information is required, let me know. Thanks!If your image is not in exact 8x10 (4x5) aspect ratio, you'll need to select the "Zoom to fit" box.
Phil -
Export layers to .png files
Hi,
I took a .psd file (made by my coworker) and redesigned it. The problem is: he organized his layers so badly...made unecessary clones.
The design is a landing page for a website, now I want to send it to my webdeveloper but he's a linux guy.
So on gimp he can't work on my .psd so well because of color formats. He asked me to cut all the images and turn them to .png
Hence I needed to run File> Script > Export Layers to files once that done I got too many similar .png as you can see (consequences of bad layers organization?)
Is that bad ? Do I need to delete unwanted/similar images to make my web dev work easier?
Last thing I saw that -in the export layers to files panel properties- transparency and trim boxes was checked and I set it to PNG24
Is it the right thing to do?
ThanksThat would be up to your web dev's needs, I guess. Since these apper to be a background image for the whole page, removing the redundant ones would only be logical.
Mylenium -
Coding Gods!
Is there a script that will:
Export Ai layers to Ai files naming the new files with the layers names?
You can do this in Photoshop.
Any help would be so appreciated
Cheers
AdsLarry G Schneider, you are a god!
Thanks so much, you have just saved me hours.
From this I found this link with all the codes on:
http://www.adobe.com/cfusion/exchange/index.cfm?from=1&o=desc&exc=17&event=productHome&s=5 &l=-1&cat=210
Cheers. -
Exporting Layers to PNG files using each layer name to create the file name??
Hi All
I'm trying to sort the following problem and was hoping somebody here could help with a scripting solution - my knowledge extends as far as actions unfortunately - which I don't think is appropriate for this.
I've created a User interface in Illustrator with many layers and have exported this as a psd with layers.
Basically what i'm wanting to do is export every layer as a png file while using the layer name to create the file name - each layer needs to be clipped.
There is no transparency in the png.
I've run the export to files script - but the names are too long and there is no anti aliasing.
I've tried running a script from Illustrator - but it doesn't see sub layers - and doesn't name the layers.
any help would be appreciated.
thanking you in advance
regards
nateHi,
We just released this tool: FERRY (http://ferry.thedamarmada.com). It does exactly what you want and a little bit more.
I think it's worth it a try.
It comes with a free demo that will export 5 layers.
Take a look and let us know if it's what you need.
It could be easily tweaked.
Jordi -
How do I export layers as individual files?
I have an animation with 24 bit colors and alpha transparency. Each frame is a layer in my project and I wish to export each individual layer as a PNG so I can create an animation in a different tool. Is there a way to do this?
Hi Arien,
If your animation program supports paste open it and select each layer,
Select>All, Edit>Copy and paste that layer into that program.
If your animation program doesn't support paste you can paste each layer
into a New file and save it as a *.png image.
Alex ., -
Export layers as png files from illustrator in multiple resolutions
suche ein aktuelles Skript. Das Skript das ich habe, wirft mir nur 3 Auflösungen aus un disz von 2012
Danke_BernhardHi Larry! Thanks for replying.
Just gave it a try, set it to 0 (it was set to 36). No luck unfortunately. I still ended up with a larger file getting exported when I turned gaussian blur back on. It also made the gaussian blur that I'm applying to the textures look really weird. That's a little unrelated though: I export textures separately that get used to make the outer edges of the texture look glowy (using a combination of gaussian blur + outer glow)
Here it is looking normal:
And here it is when I set that option to 0:
Notice the harsh lines around the edges of the object that is having gaussian blur applied to it. -
Why the exported JPG file looks like completely black?
I've already exported a PDF file by Indesign, but when I exported it to JPG file (by Acrobat), the JPG looks like almost compeletely black. But When I exported it to PNG, or Open this JPG by PS, and save it again, the image looks like normal (no black). This is PDF creating problem ( by indesign) or JPG creating problem (by Acrobat)?
Can you attach a screenshot?
*http://en.wikipedia.org/wiki/Screenshot
Use a compressed image type like PNG or JPG to save the screenshot and make sure that you do not exceed the maximum file size (1 MB).
You can try to search for a theme that looks better for you or maybe a solid persona with a suitable color.
*Themes: https://addons.mozilla.org/firefox/themes/
*Personas for Firefox | Gallery: http://www.getpersonas.com/en-US/gallery/Solid -
Export layers, with each export an extra layer is showed
Hello,
In photoshop, you can export layers to seperate files. I need this action, but a bit difference.
For instance...
- my .psd has 40 layers.
- i want to get 40 exported .png/.jpg's
- every export shows the next layer AND the previous layer(s)
The result is like this:
- export 1 = layer 1 visible, rest not-visible
- export 2 = layer 1 + layer 2 visible, rest not-visible
- export 3 = layer 1 + layer 2 + layer 3 visible, rest not-visible
- and so on
- till export 40 = all layers visible
The endresult is 40 png/jpg's and if looked at them one after an other, the picture builds up. A solution with timeline is not the answer this time.
Thanks in advance for your reply!Maybe something like this...
http://www.ps-scripts.com/bb/viewtopic.php?p=23550 -
Photoshop 6.0 SDK, export layers?
I was wondering if it would be possible to export layers to a file. For example, using an Export Module, would it be possible to take 3 layers (assuming there's only 3 layers) and write all three of these layers out to a single file, each layer being right after the other in terms of data.
Any help is greatly appreciated. Thanks.I would really appreciate a response on this.
I found out that you can use the DocumentInfo variable to access a list of layers. Unfortunately, the layer info descriptors have no data pointers. How am I supposed to read in data? I can't even read in data from the channels (not that this would be useful, since I want all the channels to act as 1 pixel).
As a side note, what is this structure:
typedef struct _PIChannelPortDesc *PIChannelPort;
Specifically _PIChannelPortDesc confuses me because I cannot find a definition. None of the above topics can be found in the SDK documentation for the CS2 SDK. ( I switched from sdk 6.0 to CS2 ) -
Modding the Export Layers to Files script to preserve .jpg quality
Please forgive me if I am posting this incorrectly, but as the thread I initially replied to is marked as Answered I started to wonder whether my question would be seen or not so I started this new thread. My original question is located in the thread http://forums.adobe.com/message/2795719#2795719 because Kari was having a similar issue to mine, but with a different file format. My original text:
I am having a similar issue, except that I need to save each layer as a .jpg, and the Export Layers to Files script is compressing the images in some fashion so that a previously seamlessly tiling layer now has a border that ruins the tile. If I save each layer individually using either the Save As command or Save for Web and Devices with the proper settings (Maximum Quality, Progressive, and Baseline Standard), the resulting images don't acquire this border, so I feel pretty certain it is something in the script that is messing up (changing the compression of) the layers, but I honestly don't know what. I have tried modifiying the jpeg portion of the script this way, hoping to prevent it from deviating from the usual Save As options:
case jpegIndex:
docRef.bitsPerChannel = BitsPerChannelType.EIGHT;
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".jpg");
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality; // 12
docRef.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
break;
but this doesn't seem to affect whatever setting is being changed. Layers saved to .jpg this way still acquire the border. I don't see what line might control whether the image is saved as progressive or not, nor anything to affect the text setting "Maximum" that I use when I successfully save each layer individually.
I am a complete novice at scripting, so please excuse/explain the obvious mistakes I may be making here.
I have since installed the script listener plug in and isolated a bit of script for saving the intended way, and hope to insert this snippet into the Export Layers as Files script, but I can tell that some of the lines are extraneous (like where it points to the file path I took), but I don't know what is safe to trim out. I sincerely appreciate any assistance with this!Here is the script that uses scriptlistner to do the jpeg save. Note I changed the name by adding '_mod' to the end to remind you that it has been edited. You can remove the origianl version by moving the file to another folder outside the scripts folder or by adding ~ at the start of the filename.
I recommend saving this as Export Layers to Files_mod.jsx. If this doesn't work for you we can try using the scriptlistener saveForWeb.
// Copyright 2007. Adobe Systems, Incorporated. All rights reserved.
// This script will export each layer in the document to a separate file.
// Written by Naoki Hada
// ZStrings and auto layout by Tom Ruark
@@@BUILDINFO@@@ Export Layers To Files.jsx 1.0.0.16
// BEGIN__HARVEST_EXCEPTION_ZSTRING
<javascriptresource>
<name>Export Layers to Files_mod...</name>
<category>layers</category>
<enableinfo>true</enableinfo>
<eventid>6f1c2cf5-4a97-4e32-8f59-f5d7a087adef</eventid>
<terminology><![CDATA[<< /Version 1
/Events <<
/6f1c2cf5-4a97-4e32-8f59-f5d7a087adef [Export Layers to Files_mod /noDirectParam <<
/message [($$$/Actions/Key/Message=Message) /char]
/destination [($$$/Actions/Key/Destination=Destination) /char]
/fileNamePrefix [($$$/Actions/Key/FileNamePrefix=Prefix) /char]
/visibleOnly [($$$/Actions/Key/CompsObject/UseVisibility=Visibility) /boolean]
/fileType [($$$/Actions/Key/FileType=File Type) /integer]
/icc [($$$/Actions/Key/PDFGenericFormat/KeepProfile=Keep Profile) /boolean]
/jpegQuality [($$$/Actions/Key/JPEGQuality=JPEG Quality) /char]
/psdMaxComp [($$$/Actions/Key/MaximizePSDCompatibility=maximize compatibility for Photoshop files) /boolean]
/tiffCompression [($$$/Actions/Key/TiffCompression=TIFF encoding) /char]
/tiffJpegQuality [($$$/Actions/Key/TIFFJPEGQuality=TIFF JPEG Quality) /char]
/pdfEncoding [($$$/Actions/Key/PDFEncoding=PDF encoding) /char]
/pdfJpegQuality [($$$/Actions/Key/PDFJPEGQuality=PDF JPEG Quality) /char]
/targaDepth [($$$/Actions/Key/Depth/TargaDepth=Targa depth) /char]
/bmpDepth [($$$/Actions/Key/Depth/BMPDepth=BMP depth) /char]
/png24Transparency [($$$/Actions/Key/Layer/PNG24PreserveTransparency=PNG 24 Preserve Transparency) /boolean]
/png24Interlaced [($$$/Actions/Key/Layer/PNG24Interlaced=PNG 24 Interlaced) /boolean]
/png24Trim [($$$/Image/Trim/PNG24=PNG 24 Trim) /boolean]
/png8Transparency [($$$/Actions/Key/Layer/PNG8PreserveTransparency=PNG 8 Preserve Transparency) /boolean]
/png8Interlaced [($$$/Actions/Key/Layer/PNG8Interlaced=PNG 8 Interlaced) /boolean]
/png8Trim [($$$/Image/Trim/PNG8=PNG 8 Trim) /boolean]
>>]
>>
>> ]]></terminology>
</javascriptresource>
// END__HARVEST_EXCEPTION_ZSTRING
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
// $.level = 0;
// debugger; // launch debugger on next line
// on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details
$.localize = true;
//=================================================================
// Globals
//=================================================================
// UI strings to be localized
//var strTitle = localize("$$$/JavaScripts/ExportLayersToFiles/Title=Export Layers To Files");
strTitle = "Export Layers To Files"
var strButtonRun = localize("$$$/JavaScripts/ExportLayersToFiles/Run=Run");
var strButtonCancel = localize("$$$/JavaScripts/ExportLayersToFiles/Cancel=Cancel");
var strHelpText = localize("$$$/JavaScripts/ExportLayersToFiles/Help=Please specify the format and location for saving each layer as a file.");
var strLabelDestination = localize("$$$/JavaScripts/ExportLayersToFiles/Destination=Destination:");
var strButtonBrowse = localize("$$$/JavaScripts/ExportLayersToFiles/Browse=&Browse...");
var strLabelFileNamePrefix = localize("$$$/JavaScripts/ExportLayersToFiles/FileNamePrefix=File Name Prefix:");
var strCheckboxVisibleOnly = localize("$$$/JavaScripts/ExportLayersToFiles/VisibleOnly=&Visible Layers Only");
var strLabelFileType = localize("$$$/JavaScripts/ExportLayersToFiles/FileType=File Type:");
var strCheckboxIncludeICCProfile = localize("$$$/JavaScripts/ExportLayersToFiles/IncludeICC=&Include ICC Profile");
var strJPEGOptions = localize("$$$/JavaScripts/ExportLayersToFiles/JPEGOptions=JPEG Options:");
var strLabelQuality = localize("$$$/JavaScripts/ExportLayersToFiles/Quality=Quality:");
var strPSDOptions = localize("$$$/JavaScripts/ExportLayersToFiles/PSDOptions=PSD Options:");
var strCheckboxMaximizeCompatibility = localize("$$$/JavaScripts/ExportLayersToFiles/Maximize=&Maximize Compatibility");
var strTIFFOptions = localize("$$$/JavaScripts/ExportLayersToFiles/TIFFOptions=TIFF Options:");
var strLabelImageCompression = localize("$$$/JavaScripts/ExportLayersToFiles/ImageCompression=Image Compression:");
var strNone = localize("$$$/JavaScripts/ExportLayersToFiles/None=None");
var strPDFOptions = localize("$$$/JavaScripts/ExportLayersToFiles/PDFOptions=PDF Options:");
var strLabelEncoding = localize("$$$/JavaScripts/ExportLayersToFiles/Encoding=Encoding:");
var strTargaOptions = localize("$$$/JavaScripts/ExportLayersToFiles/TargaOptions=Targa Options:");
var strLabelDepth = localize("$$$/JavaScripts/ExportLayersToFiles/Depth=Depth:");
var strRadiobutton16bit = localize("$$$/JavaScripts/ExportLayersToFiles/Bit16=16bit");
var strRadiobutton24bit = localize("$$$/JavaScripts/ExportLayersToFiles/Bit24=24bit");
var strRadiobutton32bit = localize("$$$/JavaScripts/ExportLayersToFiles/Bit32=32bit");
var strBMPOptions = localize("$$$/JavaScripts/ExportLayersToFiles/BMPOptions=BMP Options:");
var strAlertSpecifyDestination = localize("$$$/JavaScripts/ExportLayersToFiles/SpecifyDestination=Please specify destination.");
var strAlertDestinationNotExist = localize("$$$/JavaScripts/ExportLayersToFiles/DestionationDoesNotExist=Destination does not exist.");
var strTitleSelectDestination = localize("$$$/JavaScripts/ExportLayersToFiles/SelectDestination=Select Destination");
var strAlertDocumentMustBeOpened = localize("$$$/JavaScripts/ExportLayersToFiles/OneDocument=You must have a document open to export!");
var strAlertNeedMultipleLayers = localize("$$$/JavaScripts/ExportLayersToFiles/NoLayers=You need a document with multiple layers to export!");
var strAlertWasSuccessful = localize("$$$/JavaScripts/ExportLayersToFiles/Success= was successful.");
var strUnexpectedError = localize("$$$/JavaScripts/ExportLayersToFiles/Unexpected=Unexpected error");
var strMessage = localize("$$$/JavaScripts/ExportLayersToFiles/Message=Export Layers To Files action settings");
var stretQuality = localize( "$$$/locale_specific/JavaScripts/ExportLayersToFiles/ETQualityLength=30" );
var stretDestination = localize( "$$$/locale_specific/JavaScripts/ExportLayersToFiles/ETDestinationLength=160" );
var strddFileType = localize( "$$$/locale_specific/JavaScripts/ExportLayersToFiles/DDFileType=100" );
var strpnlOptions = localize( "$$$/locale_specific/JavaScripts/ExportLayersToFiles/PNLOptions=100" );
var strPNG8Options = localize("$$$/JavaScripts/ExportLayersToFiles/PNG8Options=PNG-8 Options:");
var strCheckboxPNGTransparency = localize("$$$/JavaScripts/ExportLayersToFiles/Transparency=Transparency");
var strCheckboxPNGInterlaced = localize("$$$/JavaScripts/ExportLayersToFiles/Interlaced=Interlaced");
var strCheckboxPNGTrm = localize("$$$/JavaScripts/ExportLayersToFiles/Trim=Trim Layers");
var strPNG24Options = localize("$$$/JavaScripts/ExportLayersToFiles/PNG24Options=PNG-24 Options:");
// the drop down list indexes for file type
var bmpIndex = 0;
var jpegIndex = 1;
var pdfIndex = 2;
var psdIndex = 3;
var targaIndex = 4;
var tiffIndex = 5;
var png8Index = 6;
var png24Index = 7;
// the drop down list indexes for tiff compression
var compNoneIndex = 0;
var compLZWIndex = 1;
var compZIPIndex = 2;
var compJPEGIndex = 3;
// ok and cancel button
var runButtonID = 1;
var cancelButtonID = 2;
// Dispatch
main();
// Functions
// Function: main
// Usage: the core routine for this script
// Input: <none>
// Return: <none>
function main() {
if ( app.documents.length <= 0 ) {
if ( DialogModes.NO != app.playbackDisplayDialogs ) {
alert( strAlertDocumentMustBeOpened );
return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
var exportInfo = new Object();
initExportInfo(exportInfo);
// look for last used params via Photoshop registry, getCustomOptions will throw if none exist
try {
var d = app.getCustomOptions("4d633fbb-ed90-480d-8e03-cccb16131a34");
descriptorToObject(exportInfo, d, strMessage, postProcessExportInfo);
catch(e) {
// it's ok if we don't have any options, continue with defaults
// see if I am getting descriptor parameters
descriptorToObject(exportInfo, app.playbackParameters, strMessage, postProcessExportInfo);
if ( DialogModes.ALL == app.playbackDisplayDialogs ) {
if (cancelButtonID == settingDialog(exportInfo)) {
return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
try {
var docName = app.activeDocument.name; // save the app.activeDocument name before duplicate.
var layerCount = app.documents[docName].layers.length;
var layerSetsCount = app.documents[docName].layerSets.length;
if ((layerCount <= 1)&&(layerSetsCount <= 0)) {
if ( DialogModes.NO != app.playbackDisplayDialogs ) {
alert( strAlertNeedMultipleLayers );
return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
} else {
var rememberMaximize;
var needMaximize = exportInfo.psdMaxComp ? QueryStateType.ALWAYS : QueryStateType.NEVER;
if ( exportInfo.fileType == psdIndex && app.preferences.maximizeCompatibility != needMaximize ) {
rememberMaximize = app.preferences.maximizeCompatibility;
app.preferences.maximizeCompatibility = needMaximize;
app.activeDocument = app.documents[docName];
var duppedDocument = app.activeDocument.duplicate();
duppedDocument.activeLayer = duppedDocument.layers[duppedDocument.layers.length-1]; // for removing
setInvisibleAllArtLayers(duppedDocument);
exportChildren(duppedDocument, app.documents[docName], exportInfo, duppedDocument, exportInfo.fileNamePrefix);
duppedDocument.close( SaveOptions.DONOTSAVECHANGES );
var d = objectToDescriptor(exportInfo, strMessage, preProcessExportInfo);
app.putCustomOptions("4d633fbb-ed90-480d-8e03-cccb16131a34", d);
var dd = objectToDescriptor(exportInfo, strMessage, preProcessExportInfo);
app.playbackParameters = dd;
if ( rememberMaximize != undefined ) {
app.preferences.maximizeCompatibility = rememberMaximize;
if ( DialogModes.ALL == app.playbackDisplayDialogs ) {
alert(strTitle + strAlertWasSuccessful);
app.playbackDisplayDialogs = DialogModes.ALL;
} catch (e) {
if ( DialogModes.NO != app.playbackDisplayDialogs ) {
alert(e);
return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
// Function: settingDialog
// Usage: pop the ui and get user settings
// Input: exportInfo object containing our parameters
// Return: on ok, the dialog info is set to the exportInfo object
function settingDialog(exportInfo) {
dlgMain = new Window("dialog", strTitle);
// match our dialog background color to the host application
var brush = dlgMain.graphics.newBrush (dlgMain.graphics.BrushType.THEME_COLOR, "appDialogBackground");
dlgMain.graphics.backgroundColor = brush;
dlgMain.graphics.disabledBackgroundColor = dlgMain.graphics.backgroundColor;
dlgMain.orientation = 'column';
dlgMain.alignChildren = 'left';
// -- top of the dialog, first line
dlgMain.add("statictext", undefined, strLabelDestination);
// -- two groups, one for left and one for right ok, cancel
dlgMain.grpTop = dlgMain.add("group");
dlgMain.grpTop.orientation = 'row';
dlgMain.grpTop.alignChildren = 'top';
dlgMain.grpTop.alignment = 'fill';
// -- group top left
dlgMain.grpTopLeft = dlgMain.grpTop.add("group");
dlgMain.grpTopLeft.orientation = 'column';
dlgMain.grpTopLeft.alignChildren = 'left';
dlgMain.grpTopLeft.alignment = 'fill';
// -- the second line in the dialog
dlgMain.grpSecondLine = dlgMain.grpTopLeft.add("group");
dlgMain.grpSecondLine.orientation = 'row';
dlgMain.grpSecondLine.alignChildren = 'center';
dlgMain.etDestination = dlgMain.grpSecondLine.add("edittext", undefined, exportInfo.destination.toString());
dlgMain.etDestination.preferredSize.width = StrToIntWithDefault( stretDestination, 160 );
dlgMain.btnBrowse = dlgMain.grpSecondLine.add("button", undefined, strButtonBrowse);
dlgMain.btnBrowse.onClick = function() {
var defaultFolder = dlgMain.etDestination.text;
var testFolder = new Folder(dlgMain.etDestination.text);
if (!testFolder.exists) {
defaultFolder = "~";
var selFolder = Folder.selectDialog(strTitleSelectDestination, defaultFolder);
if ( selFolder != null ) {
dlgMain.etDestination.text = selFolder.fsName;
dlgMain.defaultElement.active = true;
// -- the third line in the dialog
dlgMain.grpTopLeft.add("statictext", undefined, strLabelFileNamePrefix);
// -- the fourth line in the dialog
dlgMain.etFileNamePrefix = dlgMain.grpTopLeft.add("edittext", undefined, exportInfo.fileNamePrefix.toString());
dlgMain.etFileNamePrefix.alignment = 'fill';
dlgMain.etFileNamePrefix.preferredSize.width = StrToIntWithDefault( stretDestination, 160 );
// -- the fifth line in the dialog
dlgMain.cbVisible = dlgMain.grpTopLeft.add("checkbox", undefined, strCheckboxVisibleOnly);
dlgMain.cbVisible.value = exportInfo.visibleOnly;
// -- the sixth line is the panel
dlgMain.pnlFileType = dlgMain.grpTopLeft.add("panel", undefined, strLabelFileType);
dlgMain.pnlFileType.alignment = 'fill';
// -- now a dropdown list
dlgMain.ddFileType = dlgMain.pnlFileType.add("dropdownlist");
dlgMain.ddFileType.preferredSize.width = StrToIntWithDefault( strddFileType, 100 );
dlgMain.ddFileType.alignment = 'left';
dlgMain.ddFileType.add("item", "BMP");
dlgMain.ddFileType.add("item", "JPEG");
dlgMain.ddFileType.add("item", "PDF");
dlgMain.ddFileType.add("item", "PSD");
dlgMain.ddFileType.add("item", "Targa");
dlgMain.ddFileType.add("item", "TIFF");
dlgMain.ddFileType.add("item", "PNG-8");
dlgMain.ddFileType.add("item", "PNG-24");
dlgMain.ddFileType.onChange = function() {
hideAllFileTypePanel();
dlgMain.cbIcc.show();
switch(this.selection.index) {
case bmpIndex:
dlgMain.pnlFileType.pnlOptions.text = strBMPOptions;
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.show();
break;
case jpegIndex:
dlgMain.pnlFileType.pnlOptions.text = strJPEGOptions;
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.show();
dlgMain.cbIcc.hide();
break;
case tiffIndex:
dlgMain.pnlFileType.pnlOptions.text = strTIFFOptions;
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.show();
break;
case pdfIndex:
dlgMain.pnlFileType.pnlOptions.text = strPDFOptions;
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.show();
break;
case targaIndex:
dlgMain.pnlFileType.pnlOptions.text = strTargaOptions;
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.show();
break;
case png8Index:
dlgMain.pnlFileType.pnlOptions.text = strPNG8Options;
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.show();
break;
case png24Index:
dlgMain.pnlFileType.pnlOptions.text = strPNG24Options;
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.show();
break;
case psdIndex:
default:
dlgMain.pnlFileType.pnlOptions.text = strPSDOptions;
dlgMain.pnlFileType.pnlOptions.grpPSDOptions.show();
break;
dlgMain.ddFileType.items[exportInfo.fileType].selected = true;
// -- now after all the radio buttons
dlgMain.cbIcc = dlgMain.pnlFileType.add("checkbox", undefined, strCheckboxIncludeICCProfile);
dlgMain.cbIcc.value = exportInfo.icc;
dlgMain.cbIcc.alignment = 'left';
// -- now the options panel that changes
dlgMain.pnlFileType.pnlOptions = dlgMain.pnlFileType.add("panel", undefined, "Options");
dlgMain.pnlFileType.pnlOptions.alignment = 'fill';
dlgMain.pnlFileType.pnlOptions.orientation = 'stack';
dlgMain.pnlFileType.pnlOptions.preferredSize.height = StrToIntWithDefault( strpnlOptions, 100 );
// PSD options
dlgMain.pnlFileType.pnlOptions.grpPSDOptions = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpPSDOptions.cbMax = dlgMain.pnlFileType.pnlOptions.grpPSDOptions.add("checkbox", undefined, strCheckboxMaximizeCompatibility);
dlgMain.pnlFileType.pnlOptions.grpPSDOptions.cbMax.value = exportInfo.psdMaxComp;
dlgMain.pnlFileType.pnlOptions.grpPSDOptions.visible = (exportInfo.fileType == psdIndex);
// PNG8 options
dlgMain.pnlFileType.pnlOptions.grpPNG8Options = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Trans = dlgMain.pnlFileType.pnlOptions.grpPNG8Options.add("checkbox", undefined, strCheckboxPNGTransparency.toString());
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Inter = dlgMain.pnlFileType.pnlOptions.grpPNG8Options.add("checkbox", undefined, strCheckboxPNGInterlaced.toString());
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Trm = dlgMain.pnlFileType.pnlOptions.grpPNG8Options.add("checkbox", undefined, strCheckboxPNGTrm.toString());
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Trans.value = exportInfo.png8Transparency;
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Inter.value = exportInfo.png8Interlaced;
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Trm.value = exportInfo.png8Trim;
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.visible = (exportInfo.fileType == png8Index);
// PNG24 options
dlgMain.pnlFileType.pnlOptions.grpPNG24Options = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trans = dlgMain.pnlFileType.pnlOptions.grpPNG24Options.add("checkbox", undefined, strCheckboxPNGTransparency.toString());
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Inter = dlgMain.pnlFileType.pnlOptions.grpPNG24Options.add("checkbox", undefined, strCheckboxPNGInterlaced.toString());
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trm = dlgMain.pnlFileType.pnlOptions.grpPNG24Options.add("checkbox", undefined, strCheckboxPNGTrm.toString());
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trans.value = exportInfo.png24Transparency;
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Inter.value = exportInfo.png24Interlaced;
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trm.value = exportInfo.png24Trim;
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.visible = (exportInfo.fileType == png24Index);
// JPEG options
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.add("statictext", undefined, strLabelQuality);
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.etQuality = dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.add("edittext", undefined, exportInfo.jpegQuality.toString());
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.etQuality.preferredSize.width = StrToIntWithDefault( stretQuality, 30 );
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.visible = (exportInfo.fileType == jpegIndex);
// TIFF options
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.orientation = 'column';
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.visible = (exportInfo.fileType == tiffIndex);
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.alignment = 'left';
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.add("statictext", undefined, strLabelImageCompression);
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.add("dropdownlist");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.add("item", strNone);
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.add("item", "LZW");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.add("item", "ZIP");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.add("item", "JPEG");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.onChange = function() {
if (this.selection.index == compJPEGIndex) {
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.stQuality.enabled = true;
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality.enabled = true;
} else {
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.stQuality.enabled = false;
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality.enabled = false;
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.alignment = 'left';
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.stQuality = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.add("statictext", undefined, strLabelQuality);
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.add("edittext", undefined, exportInfo.tiffJpegQuality.toString());
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality.preferredSize.width = StrToIntWithDefault( stretQuality, 30 );
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality.graphics.disabledBackgroundColor = brush;
var index;
switch (exportInfo.tiffCompression) {
case TIFFEncoding.NONE: index = compNoneIndex; break;
case TIFFEncoding.TIFFLZW: index = compLZWIndex; break;
case TIFFEncoding.TIFFZIP: index = compZIPIndex; break;
case TIFFEncoding.JPEG: index = compJPEGIndex; break;
default: index = compNoneIndex; break;
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.items[index].selected = true;
if (TIFFEncoding.JPEG != exportInfo.tiffCompression) { // if not JPEG
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.stQuality.enabled = false;
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality.enabled = false;
// PDF options
dlgMain.pnlFileType.pnlOptions.grpPDFOptions = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.orientation = 'column';
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.visible = (exportInfo.fileType == pdfIndex);
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.alignment = 'left';
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.add("statictext", undefined, strLabelEncoding);
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbZip = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.add("radiobutton", undefined, "ZIP");
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbZip.onClick = function() {
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.stQuality.enabled = false;
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality.enabled = false;
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbJpeg = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.add("radiobutton", undefined, "JPEG");
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbJpeg.onClick = function() {
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.stQuality.enabled = true;
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality.enabled = true;
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.alignment = 'left';
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.stQuality = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.add("statictext", undefined, strLabelQuality);
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.add("edittext", undefined, exportInfo.pdfJpegQuality.toString());
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality.preferredSize.width = StrToIntWithDefault( stretQuality, 30 );
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality.graphics.disabledBackgroundColor = brush;
switch (exportInfo.pdfEncoding) {
case PDFEncoding.PDFZIP:
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbZip.value = true; break;
case PDFEncoding.JPEG:
default:
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbJpeg.value = true; break;
if (PDFEncoding.JPEG != exportInfo.pdfEncoding) {
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.stQuality.enabled = false;
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality.enabled = false;
// Targa options
dlgMain.pnlFileType.pnlOptions.grpTargaOptions = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.add("statictext", undefined, strLabelDepth);
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.visible = (exportInfo.fileType == targaIndex);
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb16bit = dlgMain.pnlFileType.pnlOptions.grpTargaOptions.add( "radiobutton", undefined, strRadiobutton16bit);
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb24bit = dlgMain.pnlFileType.pnlOptions.grpTargaOptions.add( "radiobutton", undefined, strRadiobutton24bit);
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb32bit = dlgMain.pnlFileType.pnlOptions.grpTargaOptions.add( "radiobutton", undefined, strRadiobutton32bit);
switch (exportInfo.targaDepth) {
case TargaBitsPerPixels.SIXTEEN: dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb16bit.value = true; break;
case TargaBitsPerPixels.TWENTYFOUR: dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb24bit.value = true; break;
case TargaBitsPerPixels.THIRTYTWO: dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb32bit.value = true; break;
default: dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb24bit.value = true; break;
// BMP options
dlgMain.pnlFileType.pnlOptions.grpBMPOptions = dlgMain.pnlFileType.pnlOptions.add("group");
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.add("statictext", undefined, strLabelDepth);
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.visible = (exportInfo.fileType == bmpIndex);
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb16bit = dlgMain.pnlFileType.pnlOptions.grpBMPOptions.add( "radiobutton", undefined, strRadiobutton16bit);
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb24bit = dlgMain.pnlFileType.pnlOptions.grpBMPOptions.add( "radiobutton", undefined, strRadiobutton24bit);
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb32bit = dlgMain.pnlFileType.pnlOptions.grpBMPOptions.add( "radiobutton", undefined, strRadiobutton32bit);
switch (exportInfo.bmpDepth) {
case BMPDepthType.SIXTEEN: dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb16bit.value = true; break;
case BMPDepthType.TWENTYFOUR:dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb24bit.value = true; break;
case BMPDepthType.THIRTYTWO: dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb32bit.value = true; break;
default: dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb24bit.value = true; break;
// the right side of the dialog, the ok and cancel buttons
dlgMain.grpTopRight = dlgMain.grpTop.add("group");
dlgMain.grpTopRight.orientation = 'column';
dlgMain.grpTopRight.alignChildren = 'fill';
dlgMain.btnRun = dlgMain.grpTopRight.add("button", undefined, strButtonRun );
dlgMain.btnRun.onClick = function() {
// check if the setting is properly
var destination = dlgMain.etDestination.text;
if (destination.length == 0) {
alert(strAlertSpecifyDestination);
return;
var testFolder = new Folder(destination);
if (!testFolder.exists) {
alert(strAlertDestinationNotExist);
return;
dlgMain.close(runButtonID);
dlgMain.btnCancel = dlgMain.grpTopRight.add("button", undefined, strButtonCancel );
dlgMain.btnCancel.onClick = function() {
dlgMain.close(cancelButtonID);
dlgMain.defaultElement = dlgMain.btnRun;
dlgMain.cancelElement = dlgMain.btnCancel;
// the bottom of the dialog
dlgMain.grpBottom = dlgMain.add("group");
dlgMain.grpBottom.orientation = 'column';
dlgMain.grpBottom.alignChildren = 'left';
dlgMain.grpBottom.alignment = 'fill';
dlgMain.pnlHelp = dlgMain.grpBottom.add("panel");
dlgMain.pnlHelp.alignment = 'fill';
dlgMain.etHelp = dlgMain.pnlHelp.add("statictext", undefined, strHelpText, {multiline:true});
dlgMain.etHelp.alignment = 'fill';
dlgMain.onShow = function() {
dlgMain.ddFileType.onChange();
// give the hosting app the focus before showing the dialog
app.bringToFront();
dlgMain.center();
var result = dlgMain.show();
if (cancelButtonID == result) {
return result; // close to quit
// get setting from dialog
exportInfo.destination = dlgMain.etDestination.text;
exportInfo.fileNamePrefix = dlgMain.etFileNamePrefix.text;
exportInfo.visibleOnly = dlgMain.cbVisible.value;
exportInfo.fileType = dlgMain.ddFileType.selection.index;
exportInfo.icc = dlgMain.cbIcc.value;
exportInfo.jpegQuality = dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.etQuality.text;
exportInfo.psdMaxComp = dlgMain.pnlFileType.pnlOptions.grpPSDOptions.cbMax.value;
index = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpCompression.ddCompression.selection.index;
if (index == compNoneIndex) {
exportInfo.tiffCompression = TIFFEncoding.NONE;
if (index == compLZWIndex) {
exportInfo.tiffCompression = TIFFEncoding.TIFFLZW;
if (index == compZIPIndex) {
exportInfo.tiffCompression = TIFFEncoding.TIFFZIP;
if (index == compJPEGIndex) {
exportInfo.tiffCompression = TIFFEncoding.JPEG;
exportInfo.tiffJpegQuality = dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.grpQuality.etQuality.text;
if (dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbZip.value) {
exportInfo.pdfEncoding = PDFEncoding.PDFZIP;
if (dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpCompression.rbJpeg.value) {
exportInfo.pdfEncoding = PDFEncoding.JPEG;
exportInfo.pdfJpegQuality = dlgMain.pnlFileType.pnlOptions.grpPDFOptions.grpQuality.etQuality.text;
if (dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb16bit.value) {
exportInfo.targaDepth = TargaBitsPerPixels.SIXTEEN;
if (dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb24bit.value) {
exportInfo.targaDepth = TargaBitsPerPixels.TWENTYFOUR;
if (dlgMain.pnlFileType.pnlOptions.grpTargaOptions.rb32bit.value) {
exportInfo.targaDepth = TargaBitsPerPixels.THIRTYTWO;
if (dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb16bit.value) {
exportInfo.bmpDepth = BMPDepthType.SIXTEEN;
if (dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb24bit.value) {
exportInfo.bmpDepth = BMPDepthType.TWENTYFOUR;
if (dlgMain.pnlFileType.pnlOptions.grpBMPOptions.rb32bit.value) {
exportInfo.bmpDepth = BMPDepthType.THIRTYTWO;
return result;
// Function: hideAllFileTypePanel
// Usage: hide all the panels in the common actions
// Input: <none>, dlgMain is a global for this script
// Return: <none>, all panels are now hidden
function hideAllFileTypePanel() {
dlgMain.pnlFileType.pnlOptions.grpPSDOptions.hide();
dlgMain.pnlFileType.pnlOptions.grpJPEGOptions.hide();
dlgMain.pnlFileType.pnlOptions.grpTIFFOptions.hide();
dlgMain.pnlFileType.pnlOptions.grpPDFOptions.hide();
dlgMain.pnlFileType.pnlOptions.grpTargaOptions.hide();
dlgMain.pnlFileType.pnlOptions.grpBMPOptions.hide();
dlgMain.pnlFileType.pnlOptions.grpPNG8Options.hide();
dlgMain.pnlFileType.pnlOptions.grpPNG24Options.hide();
// Function: initExportInfo
// Usage: create our default parameters
// Input: a new Object
// Return: a new object with params set to default
function initExportInfo(exportInfo) {
exportInfo.destination = new String("");
exportInfo.fileNamePrefix = new String("untitled_");
exportInfo.visibleOnly = false;
exportInfo.fileType = psdIndex;
exportInfo.icc = true;
exportInfo.jpegQuality = 8;
exportInfo.psdMaxComp = true;
exportInfo.tiffCompression = TIFFEncoding.NONE;
exportInfo.tiffJpegQuality = 8;
exportInfo.pdfEncoding = PDFEncoding.JPEG;
exportInfo.pdfJpegQuality = 8;
exportInfo.targaDepth = TargaBitsPerPixels.TWENTYFOUR;
exportInfo.bmpDepth = BMPDepthType.TWENTYFOUR;
exportInfo.png24Transparency = true;
exportInfo.png24Interlaced = false;
exportInfo.png24Trim = true;
exportInfo.png8Transparency = true;
exportInfo.png8Interlaced = false;
exportInfo.png8Trim = true;
try {
exportInfo.destination = Folder(app.activeDocument.fullName.parent).fsName; // destination folder
var tmp = app.activeDocument.fullName.name;
exportInfo.fileNamePrefix = decodeURI(tmp.substring(0, tmp.indexOf("."))); // filename body part
} catch(someError) {
exportInfo.destination = new String("");
exportInfo.fileNamePrefix = app.activeDocument.name; // filename body part
// Function: saveFile
// Usage: the worker routine, take our params and save the file accordingly
// Input: reference to the document, the name of the output file,
// export info object containing more information
// Return: <none>, a file on disk
function saveFile( docRef, fileNameBody, exportInfo) {
switch (exportInfo.fileType) {
case jpegIndex:
docRef.bitsPerChannel = BitsPerChannelType.EIGHT;
/*var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".jpg");
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = exportInfo.icc;
jpgSaveOptions.quality = exportInfo.jpegQuality;
docRef.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);*/
var desc= new ActionDescriptor();
var formatDesc = new ActionDescriptor();
formatDesc.putInteger( charIDToTypeID( "EQlt" ), exportInfo.jpegQuality );
formatDesc.putEnumerated( charIDToTypeID( "MttC" ), charIDToTypeID( "MttC" ), charIDToTypeID( "None" ) );
desc.putObject( charIDToTypeID( "As " ), charIDToTypeID( "JPEG" ), formatDesc );
desc.putPath( charIDToTypeID( "In " ), saveFile );
desc.putBoolean( charIDToTypeID( "Cpy " ), true );
executeAction( charIDToTypeID( "save" ), desc4, DialogModes.NO );
break;
case psdIndex:
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".psd");
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = exportInfo.icc;
psdSaveOptions.maximizeCompatibility = exportInfo.psdMaxComp;
docRef.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
break;
case tiffIndex:
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".tif");
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = exportInfo.icc;
tiffSaveOptions.imageCompression = exportInfo.tiffCompression;
if (TIFFEncoding.JPEG == exportInfo.tiffCompression) {
tiffSaveOptions.jpegQuality = exportInfo.tiffJpegQuality;
docRef.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
break;
case pdfIndex:
if (docRef.bitsPerChannel == BitsPerChannelType.THIRTYTWO)
docRef.bitsPerChannel = BitsPerChannelType.SIXTEEN;
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".pdf");
pdfSaveOptions = new PDFSaveOptions();
pdfSaveOptions.embedColorProfile = exportInfo.icc;
pdfSaveOptions.encoding = exportInfo.pdfEncoding;
if (PDFEncoding.JPEG == exportInfo.pdfEncoding) {
pdfSaveOptions.jpegQuality = exportInfo.pdfJpegQuality;
docRef.saveAs(saveFile, pdfSaveOptions, true, Extension.LOWERCASE);
break;
case targaIndex:
docRef.bitsPerChannel = BitsPerChannelType.EIGHT;
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".tga");
targaSaveOptions = new TargaSaveOptions();
targaSaveOptions.resolution = exportInfo.targaDepth;
docRef.saveAs(saveFile, targaSaveOptions, true, Extension.LOWERCASE);
break;
case bmpIndex:
docRef.bitsPerChannel = BitsPerChannelType.EIGHT;
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".bmp");
bmpSaveOptions = new BMPSaveOptions();
bmpSaveOptions.depth = exportInfo.bmpDepth;
docRef.saveAs(saveFile, bmpSaveOptions, true, Extension.LOWERCASE);
break;
case png8Index:
saveFile(docRef, fileNameBody, exportInfo, dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Inter.value, dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trans.value);
function saveFile( docRef, fileNameBody, exportInfo, interlacedValue, transparencyValue) {
var id5 = charIDToTypeID( "Expr" );
var desc3 = new ActionDescriptor();
var id6 = charIDToTypeID( "Usng" );
var desc4 = new ActionDescriptor();
var id7 = charIDToTypeID( "Op " );
var id8 = charIDToTypeID( "SWOp" );
var id9 = charIDToTypeID( "OpSa" );
desc4.putEnumerated( id7, id8, id9 );
var id10 = charIDToTypeID( "Fmt " );
var id11 = charIDToTypeID( "IRFm" );
var id12 = charIDToTypeID( "PNG8" );
desc4.putEnumerated( id10, id11, id12 );
var id13 = charIDToTypeID( "Intr" ); //Interlaced
desc4.putBoolean( id13, interlacedValue );
var id14 = charIDToTypeID( "RedA" );
var id15 = charIDToTypeID( "IRRd" );
var id16 = charIDToTypeID( "Prcp" ); //Algorithm
desc4.putEnumerated( id14, id15, id16 );
var id17 = charIDToTypeID( "RChT" );
desc4.putBoolean( id17, false );
var id18 = charIDToTypeID( "RChV" );
desc4.putBoolean( id18, false );
var id19 = charIDToTypeID( "AuRd" );
desc4.putBoolean( id19, false );
var id20 = charIDToTypeID( "NCol" ); //NO. Of Colors
desc4.putInteger( id20, 256 );
var id21 = charIDToTypeID( "Dthr" ); //Dither
var id22 = charIDToTypeID( "IRDt" );
var id23 = charIDToTypeID( "Dfsn" ); //Dither type
desc4.putEnumerated( id21, id22, id23 );
var id24 = charIDToTypeID( "DthA" );
desc4.putInteger( id24, 100 );
var id25 = charIDToTypeID( "DChS" );
desc4.putInteger( id25, 0 );
var id26 = charIDToTypeID( "DCUI" );
desc4.putInteger( id26, 0 );
var id27 = charIDToTypeID( "DChT" );
desc4.putBoolean( id27, false );
var id28 = charIDToTypeID( "DChV" );
desc4.putBoolean( id28, false );
var id29 = charIDToTypeID( "WebS" );
desc4.putInteger( id29, 0 );
var id30 = charIDToTypeID( "TDth" ); //transparency dither
var id31 = charIDToTypeID( "IRDt" );
var id32 = charIDToTypeID( "None" );
desc4.putEnumerated( id30, id31, id32 );
var id33 = charIDToTypeID( "TDtA" );
desc4.putInteger( id33, 100 );
var id34 = charIDToTypeID( "Trns" ); //Transparency
desc4.putBoolean( id34, transparencyValue );
var id35 = charIDToTypeID( "Mtt " );
desc4.putBoolean( id35, true ); //matte
var id36 = charIDToTypeID( "MttR" ); //matte color
desc4.putInteger( id36, 255 );
var id37 = charIDToTypeID( "MttG" );
desc4.putInteger( id37, 255 );
var id38 = charIDToTypeID( "MttB" );
desc4.putInteger( id38, 255 );
var id39 = charIDToTypeID( "SHTM" );
desc4.putBoolean( id39, false );
var id40 = charIDToTypeID( "SImg" );
desc4.putBoolean( id40, true );
var id41 = charIDToTypeID( "SSSO" );
desc4.putBoolean( id41, false );
var id42 = charIDToTypeID( "SSLt" );
var list1 = new ActionList();
desc4.putList( id42, list1 );
var id43 = charIDToTypeID( "DIDr" );
desc4.putBoolean( id43, false );
var id44 = charIDToTypeID( "In " );
desc4.putPath( id44, new File( exportInfo.destination + "/" + fileNameBody + ".png") );
var id45 = stringIDToTypeID( "SaveForWeb" );
desc3.putObject( id6, id45, desc4 );
executeAction( id5, desc3, DialogModes.NO );
//var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".png");
//bmpSaveOptions = new BMPSaveOptions();
//bmpSaveOptions.depth = exportInfo.bmpDepth;
//docRef.saveAs(saveFile, bmpSaveOptions, true, Extension.LOWERCASE);
break;
case png24Index:
saveFile(docRef, fileNameBody, exportInfo, dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Inter.value, dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trans.value);
function saveFile( docRef, fileNameBody, exportInfo, interlacedValue, transparencyValue) {
var id6 = charIDToTypeID( "Expr" );
var desc3 = new ActionDescriptor();
var id7 = charIDToTypeID( "Usng" );
var desc4 = new ActionDescriptor();
var id8 = charIDToTypeID( "Op " );
var id9 = charIDToTypeID( "SWOp" );
var id10 = charIDToTypeID( "OpSa" );
desc4.putEnumerated( id8, id9, id10 );
var id11 = charIDToTypeID( "Fmt " );
var id12 = charIDToTypeID( "IRFm" );
var id13 = charIDToTypeID( "PN24" );
desc4.putEnumerated( id11, id12, id13 );
var id14 = charIDToTypeID( "Intr" );
desc4.putBoolean( id14, interlacedValue );
var id15 = charIDToTypeID( "Trns" );
desc4.putBoolean( id15, transparencyValue );
var id16 = charIDToTypeID( "Mtt " );
desc4.putBoolean( id16, true );
var id17 = charIDToTypeID( "MttR" );
desc4.putInteger( id17, 255 );
var id18 = charIDToTypeID( "MttG" );
desc4.putInteger( id18, 255 );
var id19 = charIDToTypeID( "MttB" );
desc4.putInteger( id19, 255 );
var id20 = charIDToTypeID( "SHTM" );
desc4.putBoolean( id20, false );
var id21 = charIDToTypeID( "SImg" );
desc4.putBoolean( id21, true );
var id22 = charIDToTypeID( "SSSO" );
desc4.putBoolean( id22, false );
var id23 = charIDToTypeID( "SSLt" );
var list1 = new ActionList();
desc4.putList( id23, list1 );
var id24 = charIDToTypeID( "DIDr" );
desc4.putBoolean( id24, false );
var id25 = charIDToTypeID( "In " );
desc4.putPath( id25, new File( exportInfo.destination + "/" + fileNameBody + ".png") );
var id26 = stringIDToTypeID( "SaveForWeb" );
desc3.putObject( id7, id26, desc4 );
executeAction( id6, desc3, DialogModes.NO );
//var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".png");
//bmpSaveOptions = new BMPSaveOptions();
//bmpSaveOptions.depth = exportInfo.bmpDepth;
//docRef.saveAs(saveFile, bmpSaveOptions, true, Extension.LOWERCASE);
break;
default:
if ( DialogModes.NO != app.playbackDisplayDialogs ) {
alert(strUnexpectedError);
break;
// Function: zeroSuppress
// Usage: return a string padded to digit(s)
// Input: num to convert, digit count needed
// Return: string padded to digit length
function zeroSuppress (num, digit) {
var tmp = num.toString();
while (tmp.length < digit) {
tmp = "0" + tmp;
return tmp;
// Function: setInvisibleAllArtLayers
// Usage: unlock and make invisible all art layers, recursively
// Input: document or layerset
// Return: all art layers are unlocked and invisible
function setInvisibleAllArtLayers(obj) {
for( var i = 0; i < obj.artLayers.length; i++) {
obj.artLayers[i].allLocked = false;
obj.artLayers[i].visible = false;
for( var i = 0; i < obj.layerSets.length; i++) {
setInvisibleAllArtLayers(obj.layerSets[i]);
// Function: removeAllInvisibleArtLayers
// Usage: remove all the invisible art layers, recursively
// Input: document or layer set
// Return: <none>, all layers that were invisible are now gone
function removeAllInvisibleArtLayers(obj) {
for( var i = obj.artLayers.length-1; 0 <= i; i--) {
try {
if(!obj.artLayers[i].visible) {
obj.artLayers[i].remove();
catch (e) {
for( var i = obj.layerSets.length-1; 0 <= i; i--) {
removeAllInvisibleArtLayers(obj.layerSets[i]);
// Function: removeAllEmptyLayerSets
// Usage: find all empty layer sets and remove them, recursively
// Input: document or layer set
// Return: empty layer sets are now gone
function removeAllEmptyLayerSets(obj) {
var foundEmpty = true;
for( var i = obj.layerSets.length-1; 0 <= i; i--) {
if( removeAllEmptyLayerSets(obj.layerSets[i])) {
obj.layerSets[i].remove();
} else {
foundEmpty = false;
if (obj.artLayers.length > 0) {
foundEmpty = false;
return foundEmpty;
// Function: zeroSuppress
// Usage: return a string padded to digit(s)
// Input: num to convert, digit count needed
// Return: string padded to digit length
function removeAllInvisible(docRef) {
removeAllInvisibleArtLayers(docRef);
removeAllEmptyLayerSets(docRef);
// Function: exportChildren
// Usage: find all the children in this document to save
// Input: duplicate document, original document, export info,
// reference to document, starting file name
// Return: <none>, documents are saved accordingly
function exportChildren(dupObj, orgObj, exportInfo, dupDocRef, fileNamePrefix) {
for( var i = 0; i < dupObj.artLayers.length; i++) {
if (exportInfo.visibleOnly) { // visible layer only
if (!orgObj.artLayers[i].visible) {
continue;
dupObj.artLayers[i].visible = true;
var layerName = dupObj.artLayers[i].name; // store layer name before change doc
var duppedDocumentTmp = dupDocRef.duplicate();
if ((psdIndex == exportInfo.fileType)||(png24Index == exportInfo.fileType)||(png8Index == exportInfo.fileType)) { // PSD: Keep transparency
removeAllInvisible(duppedDocumentTmp);
//PNGFileOptions
if ((png24Index == exportInfo.fileType)||(png8Index == exportInfo.fileType)) { // PNGFileOptions
if ((dlgMain.pnlFileType.pnlOptions.grpPNG8Options.png8Trm.value == true)&&(png8Index == exportInfo.fileType)) { //transparancy checked?
if (activeDocument.activeLayer.isBackgroundLayer == false) { //is it anything but a background layer?
app.activeDocument.trim(TrimType.TRANSPARENT);
if ((dlgMain.pnlFileType.pnlOptions.grpPNG24Options.png24Trm.value == true)&&(png24Index == exportInfo.fileType)) { //transparancy checked?
if (activeDocument.activeLayer.isBackgroundLayer == false) { //is it anything but a background layer?
app.activeDocument.trim(TrimType.TRANSPARENT);
} else { // just flatten
duppedDocumentTmp.flatten();
var fileNameBody = fileNamePrefix;
fileNameBody += "_" + zeroSuppress(i, 4);
fileNameBody += "_" + la -
How to avoid double extension *jpg.tif when exporting layers to files?
Please help, I checked all the topics related and it seems nobody bothers about this issue.
When I do a Photomerge of a series of jpg files, Photoshop builds a multilayered file - but preserves in the name of each layer *.jpg
When I want now to export layers to files, the Scripting function will do the dumb thing and export each file with the original name - ending in JPG - , plus the extension required by me - for ex tif.
It does the same if I chose to export as jpg files and puts double extension again < *.JPG.jpg> at the end of each file exported from a layer.
I looked everywhere and couldn't find a way to solve this behavior, which forces me to do batch renames in Bridge.
The next program where I need the files (After Effects) doesn't want to import these files with double extensions.
Has anyone encountered this issue and what can be done to avoid these double extensions at Scripts/Export layers to files?
Thanks for the answerI have just altered my script so that it will remove the extentions if found.
http://www.scriptsrus.talktalk.net/Layer%20Saver.htm
Also it would be better to use :-
var layerName = activeDocument.activeLayer.name.replace(/\....$/,'');
As this way it doesn't arbitory remove the last four characters, only if it finds a fullstop.
Maybe you are looking for
-
MS Office Crashes - Multiple versions
I'd like to throw this out there and see if anyone else has run into this issue This started with Outlook (2007 and 2010) but I've found that it happens with other Office programs - Word, Excel etc... When you open Outlook, it crashes right away givi
-
How do I connect my macbook pro to show video onto the television
I am trying to connect my macbook pro to the tv so I can show the video on the computer on the tv. I have a 2014 macbook pro and was trying to do it through the hdmi port but must be doing something wrong.
-
Adobe Flash CS4 Quits when opening any file
Hello, I hope someone here can help me figure out why my Flash CS4 on a Mac 10.6.2 machine crashes unexpectedly every time I open a file. (I have posted the entire crash log below) The program will open, and even stay open when I choose a .fla file f
-
Hello BW Gurus, We have a base cube from which the data is getting pulled to a ZTABLE using ABAP program. From that ZTABLE we are using a function module and feeding the Virtual Cube. Now our issue is- our clients are running a report on base cube an
-
I'm completely new to Actionscript, is it possible to restrict access to certain pages with a log in and a password using Actionscript 3? If so, could you point me in the right direction? I'm also checking out Flex, and I wanted to see if it's possib