Edge FX 1.4 Beta

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: Tom, Kukurykus

Sebastien PICONNIER

Edge FX 1.4 Beta

Post by Sebastien PICONNIER »

Hi,

Can you let me know what you think about this script?
It is an update of the one i'va post in adobe exchange.
It makes border effects.
Here is the website where to donwload it :http://www.actiongraphik.fr
the direct link is : http://s149001944.onlinehome.fr/ActionGraphik.zip

Thanks

Bye

Seb
Sebastien PICONNIER

Edge FX 1.4 Beta

Post by Sebastien PICONNIER »

Here is the code if you want to improve it :
Code: Select all//=================================================================
// Adobe(r) Photoshop(r) CS2 & CS3 Script : ActionGraphik(r) Edge FX 1.4 Beta
//=================================================================

//=================================================================
//   Author :      Sebastien Piconnier
//   Web site :      http://www.actiongraphik.fr
//   Contact info :   contact@actiongraphik.fr
//   Copyright :   (c) Copyright 2004-2007 Sebastien Piconnier.
//               Some rights reserved.
//   License :       This work is licensed under a Creative Commons
//               Attribution-Noncommercial-Share Alike 3.0 License.
//                (http://creativecommons.org/licenses/by-nc-sa/3.0/)
//=================================================================

/* Special properties for a JavaScript to enable it to behave like an automation plug-in, the variable name must be exactly
   as the following example and the variables must be defined in the top 1000 characters of the file
   
// BEGIN__HARVEST_EXCEPTION_ZSTRING

<javascriptresource>
<name>ActionGraphik Edge FX</name>
<about>ActionGraphik Edge FX Version 1.4 Beta

© 2004-2007 Sebastien Piconnier. Some rights reserved.
Written by Sebastien Piconnier

Add an edge effect to a picture.

This work is licensed under a Creative Commons
Attribution-Noncommercial-Share Alike 3.0 License.
(http://creativecommons.org/licenses/by-nc-sa/3.0/)

Visit http://www.actiongraphik.fr for updates.</about>

<category>1-Actionpgraphik</category>
<enableinfo>true</enableinfo>
</javascriptresource>

// END__HARVEST_EXCEPTION_ZSTRING
*/

//=================================================================
//Settings
//=================================================================
#target photoshop // In case, we double-clicked the file
app.bringToFront(); // Bring to top
$.localize = true; // Enable ZString localization
#include "languages.jsxinc" // include a custom file for localization

//=================================================================
//Debugging
//=================================================================
// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
//$.level = 0;
// debugger; // launch debugger on next line

//=================================================================
// Localization strings from ZString file
//=================================================================
var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");
var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");

//=================================================================
// Custom localization string
//=================================================================
var strEdgeFXFolder = Folder(app.path+ '/' + strPresets + '/' + strScripts + '/' +"ActionGraphik/Edge FX/Masks/" ); //Path to the Edge FX masks folder

//=================================================================
// Functions
//=================================================================

      //===========================================================
      // Function: WaitForRedraw
      // Usage:    Refresh the screen, allow to see the edge effect when a
      //         dialog box is display.
      // Input: <none>
      // Return: <none>
      // NOTE: <none>
      //===========================================================
         function WaitForRedraw()
         {
         var eventWait = charIDToTypeID('Wait')
         var enumRedrawComplete = charIDToTypeID('RdCm')
         var typeState = charIDToTypeID('Stte')
         var keyState = charIDToTypeID('Stte')

         var desc = new ActionDescriptor()

         desc.putEnumerated(keyState, typeState, enumRedrawComplete)

         executeAction(eventWait, desc, DialogModes.NO)
         }

      //===========================================================
      // Function: AddALayerMask
      // Usage:    Add a layer mask to the active layer, paste the document
      //         copied before into and deselect it
      // Input: An active Layer and a docuùent on the clipboard
      // Return: A layer mask
      // NOTE: <none>
      //===========================================================
         function AddALayerMask()
         {
         var id451 = charIDToTypeID( "slct" );
         var desc110 = new ActionDescriptor();
         var id452 = charIDToTypeID( "null" );
         var ref68 = new ActionReference();
         var id453 = charIDToTypeID( "Lyr " );
         
         ref68.putName( id453, "Original picture" );
         
         desc110.putReference( id452, ref68 );

         executeAction( id451, desc110, DialogModes.NO );
         
         var id40 = charIDToTypeID( "Mk  " );
         var desc11 = new ActionDescriptor();
         var id41 = charIDToTypeID( "Nw  " );
         var id42 = charIDToTypeID( "Chnl" );
         desc11.putClass( id41, id42 );
         var id43 = charIDToTypeID( "At  " );
         var ref7 = new ActionReference();
         var id44 = charIDToTypeID( "Chnl" );
         var id45 = charIDToTypeID( "Chnl" );
         var id46 = charIDToTypeID( "Msk " );
         
         ref7.putEnumerated( id44, id45, id46 );
         
         desc11.putReference( id43, ref7 );
         
         var id47 = charIDToTypeID( "Usng" );
         var id48 = charIDToTypeID( "UsrM" );
         var id49 = charIDToTypeID( "HdAl" );
         
         desc11.putEnumerated( id47, id48, id49 );
         
         executeAction( id40, desc11, DialogModes.NO );

         var id477 = charIDToTypeID( "Shw " );
         var desc116 = new ActionDescriptor();
         var id478 = charIDToTypeID( "null" );
         var list25 = new ActionList();
         var ref70 = new ActionReference();
         var id479 = charIDToTypeID( "Chnl" );
         var id480 = charIDToTypeID( "Ordn" );
         var id481 = charIDToTypeID( "Trgt" );
         
         ref70.putEnumerated( id479, id480, id481 );
         
         list25.putReference( ref70 );
         
         desc116.putList( id478, list25 );
         
         executeAction( id477, desc116, DialogModes.NO );

         var id482 = charIDToTypeID( "past" );
         var desc117 = new ActionDescriptor();
         var id483 = charIDToTypeID( "AntA" );
         var id484 = charIDToTypeID( "Annt" );
         var id485 = charIDToTypeID( "Anno" );
         
         desc117.putEnumerated( id483, id484, id485 );
         
         executeAction( id482, desc117, DialogModes.NO );

         var id486 = charIDToTypeID( "setd" );
         var desc118 = new ActionDescriptor();
         var id487 = charIDToTypeID( "null" );
         var ref71 = new ActionReference();
         var id488 = charIDToTypeID( "Chnl" );
         var id489 = charIDToTypeID( "fsel" );
         
         ref71.putProperty( id488, id489 );
         
         desc118.putReference( id487, ref71 );
            
         var id490 = charIDToTypeID( "T   " );
         var id491 = charIDToTypeID( "Ordn" );
         var id492 = charIDToTypeID( "None" );
         
         desc118.putEnumerated( id490, id491, id492 );
         
         executeAction( id486, desc118, DialogModes.NO );

         var id6 = charIDToTypeID( "Hd  " );
         var desc3 = new ActionDescriptor();
         var id7 = charIDToTypeID( "null" );
         var list1 = new ActionList();
         var ref1 = new ActionReference();
         var id8 = charIDToTypeID( "Chnl" );
         var id9 = charIDToTypeID( "Ordn" );
         var id10 = charIDToTypeID( "Trgt" );
         
         ref1.putEnumerated( id8, id9, id10 );
         
         list1.putReference( ref1 );
         
         desc3.putList( id7, list1 );
         
         executeAction( id6, desc3, DialogModes.NO );
         }
      
      //===========================================================
      // Function: Main
      // Usage:    the main routine.
      // Input: An open document
      // Return: A document with an edge effect
      // NOTE: <none>
      //===========================================================
         function Main()
         {
         if ( app.documents.length <= 0 ) {
         alert( uiAlertDocumentMustBeOpen);
         return;
         }

         // Save the current preferences
         var startRulerUnits = app.preferences.rulerUnits
         var startTypeUnits = app.preferences.typeUnits

         // Set Adobe(r) Photoshop(r) CS3 to use pixels
         app.preferences.rulerUnits = Units.PIXELS
         app.preferences.typeUnits = TypeUnits.PIXELS

         // Get a reference to the working document
         var docRef = app.activeDocument;

         // Flatten the document
         docRef.flatten();

         // Transform background into a layer
         docRef.activeLayer.isBackgroundLayer = false;
         docRef.activeLayer.name = "Original picture";
            
         // Add a layer and renamed it
         var layerBackground = docRef.artLayers.add();
         layerBackground.name = "Background";
         layerBackground.moveToEnd(docRef); // move this layer to end

         // Fill the layer with a white colour
         var selRef = app.activeDocument.selection;
         var fillColor = new SolidColor();
         fillColor.rgb.red  = 255;
         fillColor.rgb.green = 255;
         fillColor.rgb.blue = 255;
         selRef.fill( fillColor, ColorBlendMode.NORMAL, 100, false );
         selRef = null;
         fillColor = null;

         // Display an alert
         alert( uiAlertSelectAFile );

         //Open a dialog box to select a picture into the EdgeFX masks Folder which will be used as a mask layer
         var edgeFXFile = strEdgeFXFolder.openDlg(uiTitleSelectEdgeFile,"JPEG:*.jpg;*.jpeg");
         open (edgeFXFile)

         //get a a reference to the picture
         var maskDoc = app.activeDocument;

         //Transform background into a layer and renamed it
         maskDoc.activeLayer.isBackgroundLayer = false;
            maskDoc.activeLayer.name = "Layer mask";

         //Determine if the working document is a landscape or portrait format, if it is a landscape the document used to be a mask layer is rotated
         if (docRef.width.value > docRef.height.value)
         {
         maskDoc.rotateCanvas(-90);
         }
      
         // The document "Layer mask" is resized to fit the working document   
         maskDoc.resizeImage (docRef.width, docRef.height);

         // Copy the document "Layer mask"
         maskDoc.activeLayer.copy();

         // Close the document "Layer mask" without saving it
         maskDoc.close(SaveOptions.DONOTSAVECHANGES);

         // Add the layer mask into the picture
         AddALayerMask()

         // refresh the screen to see the effect even if dialog boxes are open
         WaitForRedraw();

         // Ask if you want to flatten the document. if not some effects can be apply on the layer
         var flattenOrNot = confirm(uiAlertFlattenOrNot);
         if (flattenOrNot)
         {
         docRef.flatten();
         }
         else
         {
         }
      
         // Ask if the effect must be applied , if not we back forward to the first snapshot
         var applyOrNot = confirm(uiAlertConfirmApplyOfThisEdge);
         if (applyOrNot)
         {
         }
         else
         {
         docRef.activeHistoryState = docRef.historyStates[0];
         }

         //Reset Adobe Photoshop CS3 preferences
         app.preferences.rulerUnits = startRulerUnits
         app.preferences.typeUnits = startTypeUnits

         }
//=================================================================
// Dispatch
//=================================================================

Main();

// End of ActionGraphik Edge FX.jsx


Bye,

Seb