Skip to main content
Participant
November 19, 2023
Answered

Copying an image from a group to a frame

  • November 19, 2023
  • 3 replies
  • 458 views

Friends, please help. I have a group of photos and captions on one page. And I need to copy an image from this group into a frame on another page. For some reason, the code below copies the entire group as a whole. Maybe someone knows how to do it? I only need to copy the imported photo.

app.activeDocument.pages[6].rectangles[0].contentPlace(app.activeDocument.pages[1].groups[0].rectangles[0].allGraphics[0])
This topic has been closed for replies.
Correct answer vistarmedia@gmail.com

I solved the problem in a workaround using the "place" command. Below is the code I used, but still, I hope someone found a more correct way through the "contentPlace" command.

app.activeDocument.pages[6].rectangles[0].place(File(app.activeDocument.pages[1].groups[0].allGraphics[0].itemLink.filePath));

 

3 replies

Peter Kahrel
Community Expert
Community Expert
November 20, 2023

Why do you think that contentPlace() is more correct than place()?

 

Instead of re-placing the graphic, you could duplicate its parent (the rectangle it sits in):

app.activeDocument.pages[1].groups[0].rectangles[0].duplicate (
  app.activeDocument.pages[6]
)

 and position it  using the move() function.

Participant
November 20, 2023

Thank you for answering, Peter! The fact is that my script collects images from several pages of one alternative layout and puts everything in one page of another alternative layout. The number of images I have is constantly changing from 8 to 40 pcs. Therefore, the option you proposed does not suit me, unfortunately. I use duplicate() in cases where the number of pages and images in both layouts is the same. And contentPlace() seems right to me because it creates a copy of the existing link, as I think, and does not access the file on the hard disk as place() does. But I could be wrong, of course.

Peter Kahrel
Community Expert
Community Expert
November 20, 2023

> contentPlace() seems right to me because it creates a copy of the existing link, as I think, and does not access the file on the hard disk as place() does

 

I don't think it makes much difference. In both cases you end up with two (or more) links to the same disk image.

Robert at ID-Tasker
Legend
November 19, 2023

You either need to Cut/Copy&Paste or use parent container as a reference object - or like you've done in your workaround - use Link's info.

 

vistarmedia@gmail.comAuthorCorrect answer
Participant
November 19, 2023

I solved the problem in a workaround using the "place" command. Below is the code I used, but still, I hope someone found a more correct way through the "contentPlace" command.

app.activeDocument.pages[6].rectangles[0].place(File(app.activeDocument.pages[1].groups[0].allGraphics[0].itemLink.filePath));