Cut photo in half along curved path
Learn / Forums / General InDesign Topics / Cut photo in half along curved path
- This topic has 6 replies, 3 voices, and was last updated 7 years, 9 months ago by Matt Isaac.
-
AuthorPosts
-
-
May 24, 2016 at 11:22 am #85149Nicholas CucciaMember
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.
-
May 24, 2016 at 12:08 pm #85150Matt IsaacParticipant
- copy the image and place in place.
- use the pen tool to create a path through the image and close the path below th image.
- shift click the image to select both the image and path
- use pathfinders to ‘subtract’
- copy the current selection and paste in place so the top half is duplicated over the image.
- shift click the bottom of the image to select the top half and full image and use pathfinder to ‘subtract’ again.
this will get the top half of the image you want
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.
-
May 24, 2016 at 9:38 pm #85184Nicholas CucciaMember
Thanks. This worked after a few tries …..
Nick-
May 25, 2016 at 2:01 pm #85223Matt IsaacParticipant
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.
-
June 16, 2016 at 1:54 pm #85848Matt IsaacParticipant
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.
-
June 16, 2016 at 4:26 pm #85851Ari SingerMember
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.
-
June 17, 2016 at 5:13 am #85857Matt IsaacParticipant
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.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.