• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How Select and Iterate All Photo Images and Apply Fixes (Javascript, Illustrator, macOS)?

Community Beginner ,
Oct 26, 2021 Oct 26, 2021

Copy link to clipboard

Copied

Dear JS/Illustrator Mavens,
  • Seeking suggestions/examples to get started on a first JS/Illustrator coding attempt.
CONTEXT
With Javascript on macOS (Monterey; v12.0.1) applied to manipulate ~2,000 photo images “placed” using Snap-to-Grid into a single Adobe Illustrator 2021 .AI file (some photos were placed a single Artboard, other photos were places in various clusters around the Canvas), how can:
  1. All photo images (regardless of whether they are on the Artboard or floating around the Canvas), be selected and included in a single JS Collection?
  2. Then, while iterating over the collection of photos, manipulate them? Specific manipulations include:
  • Force size of all photos to be 360px x 360px?
  • Determine if each image is, in fact, aligned using Snap-to-Grid?
  • If not, force the image to Snap-to-Grid.
  • Determine the rotation of each image; then—as needed—force rotation to one of exactly {0°/360°, 90°, or 270°}? 
  • Some of the images are slightly off and need to be “nudged” into exact placement. Examples: 90.021, 89.988.
  • Force the edges of photos to perfectly align with their neighbors (as applicable: top, bottom, left, right) without any space between them? 

WHY?

Many images in the file reflect 360px x 360px, Snap-to-Grid, and appropriate rotation (e.g., 90°, 270°), yet have ~1 px white lines separating them both in Illustrator and generated PDFs.

  • This coding effort is being undertaken with hopes of eliminating the unwanted white lines.
Many, many thanks in advance!
Plane Wryter
TOPICS
Scripting

Views

308

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guide ,
Oct 27, 2021 Oct 27, 2021

Copy link to clipboard

Copied

Snapping to a grid is not an option. Unless somebody thinks of an inspired way to decide what the new position of each item should be, you're at a dead end.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

You’re right that snap-to-grid isn’t a feature accessible to scripting but I’m guessing OP just wants to position items precisely, which is trivial to do.

 

It would be helpful if OP could post screenshots of example artwork before and after, to clarify their original description.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

I presume the OP wants something like this:

 

Untitled1.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

Could be. Best if OP can supply real before and after examples as screenshots and/or attachments.

Re. thin lines appearing between images, that might be because there’s an actual gap between the elements in the artwork, or it could just be a display artefact of the PDF viewer. If the latter, I would suggest making the images fractionally larger than the grid they’re laid out on, so that their edges just very slightly overlap.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

LATEST

Commendations, femkeblanco!

Your depiction of what I'm striving to accomplish is correct.

Your image (above) shows "CURRENT_CONDITION" (on the left) and "DESIRED_RESULT" (on the right). 

Via another post to this forum, "Manan" suggested a basic approach (see code snippet below) to accumulate all the images in a JS variable, then iterate over the collection in order to make the desired adjustments. 

If you have a free moment, your thoughts on the approach are invited.

Here's Manan's code snippet: 

var pi = app.documents[0].placedItems for(var i = 0; i < pi.length; i++) { alert(pi[i].file) }

With thanks,

Plane Wryter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines