Reply To: Cut photo in half along curved path

Home Page / Forums / General InDesign Topics (CLOSED) / Cut photo in half along curved path / Reply To: Cut photo in half along curved path

#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.

This article was last modified on June 16, 2016

Comments (0)

Loading comments...