Sample Scripts Installed with Photoshop Scripting PluginsAppleScript Alpha Channel From Text Demonstrates how to create a new text item and convert it into an alpha channel. Apply Text Style This script will get every art layer in the active document. It will then analyze each layer to determine if it is a text art layer. If it is, then it will set the size of the text in the layer to 20 point, change the direction of the text to vertical and apply the layer style “SummerSky” to the text. Batch Convert For each document in a selected folder: 1. Duplicate the original document 2. Add document information to the document 3. Save the document as a JPEG with the new document information. The file name will have the format Temp00x where x is the file number. 4. Close the newly saved document. 5. Duplicate the original document a second time 6. Create a 100x100 thumbnail of the image 7. Save the thumbnail document as a JPEG file. The file name will have the format Thumbnail00x where x is the file number. When all documents are converted, it will close all open documents. Convert Colors Demonstrates how to convert a CMYK color to an RGB color, how to convert the foreground color to an RGB color, and how to convert an RGB color to its hexadecimal equivalent. Create New Text Item Demonstrates how to create a new text item by first creating a new art layer, specifying its kind and then setting the contents of the text item. Crop Creates a new document and then crops the document bounds by considering the angle, resolution, width and height. Crop and Rotate ArtLayers Iterates through every text layer of the current document and crops and rotates each of them at a 45 degree angle. Get Document By Name
Shows how to retrieve a document by name rather than by index. This is thepreferred way of retrieving a document because get by index is not alwaysreliable.Get Text Item CenterShows how to find the center point of a text item. It will demonstrate how todetermine if an art layer is a text layer and how to use the properties of the textitem.Layer styleApplies a layer style to the first layer of a new document. It demonstrates how touse the background layer of the current document.Make SelectionThis script will select a region in the active document. It will then copy theselection to the clipboard and paste the contents of the clipboard into a newdocument.Make Warp TextThis script will make a new text layer in a new document and set the contents ofthe text item in the new text layer. It will then set the point size of the text, thecolor, and the warp style and warp bend of the text item.New DocumentShows how to create a new document and specifying its width and height andunits.Run JavaScriptThis script will run the JavaScript named MosaicTiles.js, which is assumed to bein the current directory. A copy of the MosaicTiles.js script is located in theJavaScript sample scripts folder.Save As TIFFCreates a new document and saves it as a TIFF file, using TIFF save options.TrimTrims the current document and demonstrates how to use the options of the trimcommand.UnitTypesThis script will create a new document and a new text layer. It will thendemonstrate how to use units for setting position, width, height, baseline shift, leftindent, first line indent and space before.
Visual Basic Art layer style Demonstrates how to apply a layer style to a layer. The layer styles are applied by style name, so in non-English versions of the application, this name will need to be modified to match the localized style name. Batch Process: For each document in a selected folder: 1. Duplicate the original document 2. Add document information to the document 3. Save the document as a JPEG with the new document information. The file name will have the format Temp00x where x is the file number. 4. Close the newly saved document. 5. Duplicate the original document a second time 6. Create a 100x100 thumbnail of the image 7. Save the thumbnail document as a JPEG file. The file name will have the format Thumbnail00x where x is the file number. When all documents are converted, it will close all open documents. Clipboard interaction This script will create a new target document which is 4 inch x 4 inch document, select the contents of the source document and copy it to the clipboard, and then paste the contents of the clipboard into the target document. Notice that the script sets the active document prior to doing the cut and paste because these operations only work on the active document. Create and Execute Action This script creates an action, which is equivalent to the Mosaic Tiles action and executes it. Duplicate layers This script demonstrates how to add a LayerSet and then duplicate the top layer and place it into the Layer Set. Execute Action This script executes the \"Molten Lead\" action, which is in the Photoshop actions palette. If using a non-English version of Photoshop, you may have to change the name of the action to match an appropriate action in your actions palette. Execute JavaScript This script demonstrates how to execute a JavaScript from within a Visual Basic application. The script MosaicTiles.js is located in the JavaScript folder.
FiltersIf there is an active document, this script will create four different selections andapply a different filter to each one of the selections. The filters applied are “Dustand Scratches,” “Despeckle,” “Diffuse Glow,” and “Glass Effect.” After allfilters are applied, the last selection is deselected.Get Document By NameShows how to retrieve a document by name rather than by index. This is thepreferred way of retrieving a document because get by index is not alwaysreliable.History StateShows how to use the history state of a document to rewind to a previousdocument state. You can actually simulate an “undo” command by saving yourprevious history state and resetting it.New Text ArtDemonstrates how to create a new text item by first creating a new art layer,specifying its kind and then setting the contents of the text item.Open DocumentShows how to do a basic document open.Save FormatsDemonstrates how to use SaveOptions in Photoshop. The script will save theactive document in PDF, JPEG and Photoshop formats.SelectionThis script will select a region in the active document. It will then copy theselection to the clipboard and paste the contents of the clipboard into a newdocument.Selection effectsThis script demonstrates how to stroke and fill the current selection. This scriptdraws a black stroke around the selection and then fills it with red.Text artThis script shows how to determine if a layer is a text layer and how to apply tofilter to a selection on the layer. The text layer must be rasterized before applyingfilters to it.Before running the script, create one or more text layers in the active documentText art centerThis script will calculate the geometric center of each text item of a document
Transform Art This script will iterate through all of the layers of a document. If the layer is not a text layer, then it will invert the contents of the layer. If it is the background layer, the entire canvas will be cropped and rotated. In order to invert the entire document, each layer must be inverted independently. Trim document This script demonstrates how to trim either the left and right edges of a document or the top and bottom edges of the document.JavaScript ActiveLayer.js This script demonstrates how to set the active layer to the last art layer of the active document or the first if the last is already active. ApplyFilters.js If there is an active document, this script will create four different selections and apply a different filter to each one of the selections. The filters applied are “Dust and Scratches,” “Despeckle,” “Diffuse Glow,” and “Glass Effect.” After all filters are applied, the last selection is deselected. ApplyLayerStyle.js Demonstrates how to apply a layer style to a layer. The layer styles are applied by style name, so in non-English versions of the application, this name will need to be modified to match the localized style name. Compare colors.js This script demonstrates how to compare the application foreground color to the application background color. Convert Colors.js Converts the application foreground color to an RGB color. CopyAndPaste.js This example makes a creates a selection in the active document, copies the selection, to the clipboard, creates a new document of the same dimensions and pastes the contents of the clipboard into it. It ensures that rulerUnits are set before creating the new document. It checks the kind of the layer before making the selection to be sure not to copy a text layer. CropAndRotate.js Crop a 10-pixel border from the image, and rotate the active document by 45 degrees. Emboss.js
Demonstrates how you can use the action manager to execute the Emboss filter.ExecuteMoltenLead.jsThis script demonstrates how to use the action manager to execute a previouslydefined action. The name of the action comes from Photoshop’s Actions Paletteand may be different if running a non-English version of Photoshop.FillSelection.jsFill the current selection with an RGB color. It checks to make sure the activelayer is not the background layer. It also assumes that there is an active selectionin the document.LayerKind.jsThis script demonstrates how to create a new layer and set its kind to text.LinkLayers.jsThis script creates two new art layers and then links the second layer to the first.LoadSelection.jsThis script will demonstrate how to load a selection from a saved alpha channel.MakeSelection.jsThis script will select a region in the active document, replacing any previousselection.MosaicTiles.jsThis script demonstrates how you can use the action manager to execute theMosaic Tiles filter.MoveToLayerSet.jsThis script will demonstrate how to duplicate the first layer and move it to the endof a new layer set.NewDocument.jsCreate a new Photoshop document with dimensions 4 inches by 4 inches. Makesure to set the ruler units prior to creating the document.OpenDocument.jsOpen a Photoshop document located in the Photoshop samples folder on thePhotoshop CD. You must first create a File object to pass into the open method.RotateLayers.jsThis script demonstrates how to rotate a layer 45 degrees clockwise.RulerUnits.js
This script demonstrates how to suppress all dialogs and then use the ruler units tocreate a 4-inch by 4-inch document. It will then create another document of thesame size, but specified instead in pixel units.Selection Stroke.jsCreates a selection and create a border around it. The script then sets the strokecolor and width of the new stroke.SetChannels.jsAssuming there are “Red” and “Blue” channels in your document, make the“Red” and “Blue” channels the active channels of the document.WorkingWithText.jsThis script will create a new art layer and convert it to a text layer. It then sets itscontents, size and color.
Search
Read the Text Version
- 1 - 7
Pages: