Cut photo in half along curved path

Learn / Forums / General InDesign Topics / Cut photo in half along curved path

Viewing 2 reply threads
  • Author
    Posts
    • #85149

      Hi. I know I can use the Scissors tool to cut a photo in pieces along a straight line. Is there a way to make that line a curved path first, i.e., with pen tool? Or do I have to do this in Photoshop or Illustrator? I’m using an image in a layout that I have at top and bottom and I want the cutaways to mirror each other.

    • #85150
      Matt Isaac
      Participant
      1. copy the image and place in place.
      2. use the pen tool to create a path through the image and close the path below th image.
      3. shift click the image to select both the image and path
      4. use pathfinders to ‘subtract’
      5. this will get the top half of the image you want

      6. copy the current selection and paste in place so the top half is duplicated over the image.
      7. shift click the bottom of the image to select the top half and full image and use pathfinder to ‘subtract’ again.
      8. if done correctly you will end with two frames that split the image

      I hope this works for you.. if Ari S. sees this he may be able to write a script for this that would be much simpler but i have no scripting knowledge as of now though i do plan to learn.

    • #85184

      Thanks. This worked after a few tries …..
      Nick

      • #85223
        Matt Isaac
        Participant

        I am going to try my hand at writing a script for this but Like i said before.. I have NO scripting knowledge, this will be my first attempt so it may take a while.

      • #85848
        Matt Isaac
        Participant

        Here is the script. I had some difficulty with the pathfinder so I enlisted the help of Ari who created a script to do this. Here is Ari’s script:

        app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Subtract Paths");
        function main() {
            try{
                var mySelection = app.selection;
                var myPicture = mySelection[0];
                var myPath = mySelection[1];
                var topPicture = myPicture.duplicate();
                var half1 = myPath.subtractPath(myPicture);
                var newPath = half1.duplicate();
                var half2 = newPath.subtractPath(topPicture);
                var myGroup = half1.parent.groups.add ([half1, half2]);
                app.select(myGroup);
                } catch(myError) {
                    alert("Make sure you selected 2 path items")
                    }
                }

        Here is my script with Ari’s assistance in the pathfinder portion and the thought of adding undo:

        //Scripted by Skemicle
        //with assistance from Ari S
        if (parseFloat(app.version) < 6)
        main();
        else
        app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Splice Image Along Path");
        function main() {
        	if(app.selection.length == 2){
        		var sel = app.selection;
        		var orig = sel[0];
        		var path = sel[1];
        		var top = sel[0].duplicate();
        		path.subtractPath(top);
        		var half1 = top.duplicate();
        		top.subtractPath(orig);
        		app.selection = null;
        	}
        	else{
        		alert("Please, make sure you have selected an image and an overlapping path.");
        	}
        }

        Both scripts do basically the same thing. the main difference is that Ari’s script groups the two halves of the image and leaves the group selected while my script leaves the two halves ungrouped and nothing selected.

      • #85851
        Ari Singer
        Member

        Well done, Skemicle.

        I noticed that you used an if/else statement instead of a try/catch. The reason I used try/catch is because a bunch of things could go wrong in the script even if the selection only contains two items (such as an object that is not a valid path and can’t get subtracted etc.) and the script would crash with a nasty error.

        But with the try/catch block, I present a user-friendly alert to the user notifying of the issue, without crashing the script. And this also eliminates the need of an if/else statement.

      • #85857
        Matt Isaac
        Participant

        Yeah i tried to work the try/catch block into my script but without copy/pasting yours i couldn’t get it to work so i just went with what i knew. I will experiment with try/catch and eventually get the hang of it.
        —–
        Turns out the try/catch statement works just as the if/else statement.
        —–
        Here is my updated script:

        //Scripted by Skemicle
        //with assistance from Ari S
        if (parseFloat(app.version) < 6)
        main();
        else
        app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Splice Image Along Path");
        function main() {
        	try{
        		var sel = app.selection;
        		var orig = sel[0];
        		var path = sel[1];
        		var top = sel[0].duplicate();
        		path.subtractPath(top);
        		var half1 = top.duplicate();
        		top.subtractPath(orig);
        		app.selection = null;
        	}
        	catch(error){
        		alert("Please, make sure you have selected an image and an overlapping path.");
        	}
        }

        Thanks for your assistance Ari.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>
Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo