Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Fake Duotone in InDesign

Return to Member Forum

  • Author
    Posts
    • #98500
      Masood Ahmad
      Participant

      Hello Everyone,

      I had a script with me (originally created by Ari S.) and I tweaked it for some fun. I wanted to make Fake Duotone in InDesign.

      Below listed (edited) script does the following:

      1) creates two duplicates of the selected image, i.e. making a total of 3 images.
      2) Top image is set to Luminosity, Middle to Multiply and the bottom to Normal;
      3) Grouped the three images.

      What I wanted is to:
      4) Delete the content (image) from the bottomObject and apply a new colour-fill to the frame.
      5) The new colour will be called “Duotone” with CMYK values as: 75/5/100/0.
      6) If “Duotone” colour already exists, then skip point 5.
      7) Finally group all the three objects.

      Can someone complete the remaining part.

      app.scriptPreferences.enableRedraw = false;
      app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Image Manipulation Script");

      function main(){
      try{
      var mySelection = app.selection[0];
      var bottomObject = mySelection;
      var topObject = bottomObject.duplicate();
      var midObject = bottomObject.duplicate();
      topObject.transparencySettings.blendingSettings.blendMode = BlendMode.LUMINOSITY;
      midObject.transparencySettings.blendingSettings.blendMode = BlendMode.MULTIPLY;
      bottomObject.transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;

      try {
      var myGroup = bottomObject.parent.groups.add ([bottomObject, midObject, topObject]);
      app.select(myGroup);
      }
      catch (myError) {
      alert("could not group successfully");
      }

      }
      catch (myError){
      alert("Make sure you selected a graphic frame");
      }
      }

    • #98501
      Masood Ahmad
      Participant

      Sorry, small correction in point # 6.

      6) If “Duotone” colour already exists, then skip the creation of Duotone in point #5 and simply apply the Duotone color to the bottomObject.

    • #98516
      Masood Ahmad
      Participant

      After a lot of hit and trials, I came up with this:


      //Fake Duotone in InDesign
      //Edited by: Masood Ahmad, 29th September 2017
      //Original Script created by: Ari S. - designerjoe@outlook.com

      app.scriptPreferences.enableRedraw = false;
      app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Image Manipulation Script");

      function main(){
      try{
      var mySelection = app.selection[0];
      var bottomObject = mySelection;
      var topObject = bottomObject.duplicate();
      var midObject = bottomObject.duplicate();
      topObject.transparencySettings.blendingSettings.blendMode = BlendMode.LUMINOSITY;
      midObject.transparencySettings.blendingSettings.blendMode = BlendMode.MULTIPLY;
      bottomObject.transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;

      // Find Duotone swatch position
      var myDoc = app.activeDocument;
      var mySwatches = myDoc.swatches;
      var swatchesLength = mySwatches.length;
      for (i=0;i<swatchesLength;i++) {
      if (mySwatches[i].name == "duotone" || mySwatches[i].name == "Duotone") {
      var duotoneSwatch = mySwatches[i];
      bottomObject.fillColor = duotoneSwatch;
      }
      }

      // Check if Duotone swatch is defined
      if (duotoneSwatch == undefined) {
      //alert("Please create a Duotone swatch");
      var myColor = myDoc.colors.add();
      myColor.colorValue = [75,5,100,0];
      myColor.name = "Duotone";
      bottomObject.fillColor = myColor;
      }

      try {
      var myGroup = bottomObject.parent.groups.add ([bottomObject, midObject, topObject]);
      app.select(myGroup);
      }
      catch (myError) {
      alert("could not group successfully");
      }
      }
      catch (myError){
      alert("Make sure you selected a graphic frame");
      }
      }

      The scripts works well and duly checks, create and apply the Duotone swatch.

      The only part remaining in the script is to:
      1) Delete the image (content) from the bottomObject i.e. keep the bottom frame but delete its content image.

      Last but not the least, clean-up the script to avoid unnecessary codes.

      Thanks in advance.

    • #98526
      Masood Ahmad
      Participant

      Wow! I couldn’t believe, I’ve finally completed my scripts. Initially, it was a sort of challenge to me as I’m not a script writer, but it was interesting.

      Here is my final code:


      //Fake Duotone in InDesign
      //Edited by: Masood Ahmad, 29th September 2017
      //Original Script created by: Ari S. - designerjoe@outlook.com

      app.scriptPreferences.enableRedraw = false;
      app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Image Manipulation Script");

      function main(){
      try{
      var mySelection = app.selection[0];
      var bottomObject = mySelection;
      var topObject = bottomObject.duplicate();
      var midObject = bottomObject.duplicate();
      //apply blending modes to all the three objects
      topObject.transparencySettings.blendingSettings.blendMode = BlendMode.LUMINOSITY;
      midObject.transparencySettings.blendingSettings.blendMode = BlendMode.MULTIPLY;
      bottomObject.transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;

      // Find Duotone swatch and apply the fill to the bottom object
      var myDoc = app.activeDocument;
      var mySwatches = myDoc.swatches;
      var swatchesLength = mySwatches.length;
      for (i=0;i<swatchesLength;i++) {
      if (mySwatches[i].name == "duotone" || mySwatches[i].name == "Duotone") {
      var duotoneSwatch = mySwatches[i];
      bottomObject.fillColor = duotoneSwatch;
      }
      }

      // Check if Duotone swatch is defined, if not create and apply the fill to the bottom object
      if (duotoneSwatch == undefined) {
      //alert("Please create a Duotone swatch");
      var myColor = myDoc.colors.add();
      myColor.colorValue = [75,5,100,0];
      myColor.name = "Duotone";
      bottomObject.fillColor = myColor;
      }

      //delete the image (content) from the bottom most object
      myGraphics = bottomObject.allGraphics;
      try {myGraphics[0].remove()} catch(_){}

      //group all the three objects.
      try {
      var myGroup = bottomObject.parent.groups.add ([bottomObject, midObject, topObject]);
      app.select(myGroup);
      }
      catch (myError) {
      alert("could not group successfully");
      }
      }
      catch (myError){
      alert("Make sure you selected a graphic frame");
      }
      }

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
Forum Ads