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

scaling a pattern to fill a selection in Photoshop

Explorer ,
Apr 29, 2024 Apr 29, 2024

I’d like to create a Photoshop action to automatically fill a selection with another image and scale the image to fit to cover the selection.

 

For example, I’d like the action to fill a circle with the image below.

 

I tried defining a pattern, but I wasn’t able to find a script that would either create a single instance of the pattern or scale the pattern down to cover the selection.

 

Is there a pattern script that will scale a pattern to fit to cover a selection?

 

Or will another Photoshop tool do this?

 

X.png

 

 

 

 

TOPICS
Actions and scripting , Windows
385
Translate
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
LEGEND ,
Apr 29, 2024 Apr 29, 2024

You may need to write a custom script. You can get the size by selection.bounds and then get the fill bounds (say, another layer) using layer.bounds then scale with layer.resize().

Translate
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
Participant ,
Apr 29, 2024 Apr 29, 2024

One thing you could do is clip the circle layer to the image layer and then resize the image layer to cover (in either order). Scaling to cover means you calculate the scale factor to match both height and width and then take the maximum. When doing this, I typically scale it an extra pixel on each side to prevent anti-aliased edges from showing up in the clipped area. Below is the scriptListener function that clips the active layer to the one below.

 

function ClipActiveLayer() {
  var d = new ActionDescriptor()
  var r = new ActionReference()
  r.putEnumerated( chID( "Lyr " ), chID( "Ordn" ), chID( "Trgt" ) )
  d.putReference( chID( "null" ), r)
  executeAction( chID( "GrpL" ), d, DialogModes.NO )
}

 

 

Translate
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
People's Champ ,
Apr 29, 2024 Apr 29, 2024
Translate
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 Expert ,
Apr 29, 2024 Apr 29, 2024
LATEST

Or will another Photoshop tool do this?

 

Data-driven graphics can automatically scale to layer bounds, but I am not aware if scripts can utilize this feature. This functionality can certainly be applied manually or by using a pre-existing data list, especially when aiming to populate a defined area with multiple pre-prepared images.

Translate
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