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

detect empty canvas space in fill it with content-aware tool

Explorer ,
May 23, 2023 May 23, 2023

Is there any way in photoshop to automate content-aware fill-in the empty space (caused by canvas resize) of images in batch?

TOPICS
Actions and scripting
2.2K
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
Community Expert ,
May 23, 2023 May 23, 2023

I have some ideas, there isn't a default native method that comes to mind as I type.

 

Have all images had their canvas resized? Or is there a mixture of images?

 

Was the canvas extended with transparent pixels, or opaque pixels such as white?

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
Explorer ,
May 23, 2023 May 23, 2023

All images are resized to one size that is 800px*1000px(smart object). When all are resized to this size, some images expose transparent pixels. I want all those transparent pixels to be automatically content aware filled. Is that possible?

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 ,
May 23, 2023 May 23, 2023

The reply from @jefbr should get you there, but if you wish to preserve the smart object layer then a slightly different approach may be required.

 

An action or script could do this.

 

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
Contributor ,
May 23, 2023 May 23, 2023

yes there is.

 

  1. flatten the document before you change the canvas (you now have only the background layer.)
  2. copy the background layer to a new layer
  3. extend the canvas as you want it
  4. select layer contents
  5. inverse the selection
  6. do content-aware fill
  7. deselect
  8. stop recording the action

 

you're done.

 

 

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 ,
May 23, 2023 May 23, 2023

You might want to add extending the selection by a couple pixels into the image area just so that there is no change of a line forming between the content aware fill area and the original image. Maybe this isn't an issue.

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 ,
May 23, 2023 May 23, 2023

Always useful to have a px or two overlap!

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
Contributor ,
May 23, 2023 May 23, 2023

This is a good idea in the case where you want to preserve the layers or the smart object.

If you flatten, you guarantee that there is no content in the extended zones.

 

You could also do this 

 

  1. select all layers
  2. group layers
  3. select entire canvas*
  4. apply mask to group
  5. extend canvas
  6. make a new layer with merge visible
  7. make a selection of the group layer mask 
  8. inverse the selection
  9. expand selection 2px
  10. do content-aware fill
  11. inverse the selection
  12. delete layer content
  13. deselect
  14. stop recording

 

*without selecting the entire canvas, the mask is not actually set and will remain white after expanding. By selecting an area, after extending the canvas, the expanded area will be black.

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
Explorer ,
May 23, 2023 May 23, 2023

can this be automated via action or script on images that have different sizes of transparent canvas pixels?

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 ,
May 23, 2023 May 23, 2023

Yes!

 

One way is CTRL/CMD click on the layer panel thumbnail to load the transparency as a selection in the action recording.

 

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
Contributor ,
May 23, 2023 May 23, 2023
LATEST

Yes, when you record the steps I described above in an action, you have something the solution*.

 

*something that I think answers your needs and incorporates the feedback of others.

 

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