1

I would like to increase the border width of a yellow image border and perform this action within a batch process for multiple similar images within Photoshop.

So far I performed the following steps and tried to save them as "actions" to allow their use in batch processing:

  • increase canvas size around the image with the thin yellow border
  • select the white area (created by the increased canvas size) around the image using the magic wand tool
  • perform content aware fill. This step is performed to ensure best results, as the yellow colour of the thin border around the images is not completely homogenous and the yellow tone also varies slightly between images. As sampling area I chose "custom" and selected the yellow border using the sampling brush tool.

The problem is, that the last step fails within batch processing multiple similar images. I think the reason is that the "custom" selected sampling area can't be applied in a batch process.

I would appreciate any advice on how to automate this action. Thanks!

enter image description here

0

2 Answers 2

1

I don't know why you are using "content aware". Maybe I'm missing something. It's not working as you are expecting because the "content" you have selected, based on the steps described, is white. So it's using the white content to fill the area, well, white.

Assuming it's a 1 layer, flat, no transparency, "Background layer" image

  1. Set the background color to the yellow
  2. Increase canvas size
  3. Done

For a "flat" image, whatever color the background color is set to will be the color of the additional canvas area when you increase the canvas size by default. (There are options to change this as shown in the animation above.)


Based on comments regarding some slight variations in the existing yellow border, I would....

  • Set the background color to the yellow.
  • Select All
  • Select > Modify > Contract
  • 20px (or whatever you feel is correct), and tick Apply effect at canvas bounds
  • Select > inverse
  • Edit > Fill - Background Color, normal, 100%
  • Image > Canvas Size - enter values and hit OK

enter image description here

There's no "magic wand" here, nothing which requires a "user click". It can all be automated easily. This does assume all the cards have relatively the same 20px border - or if they don't - a slight 1-2px edge around the inner artwork, where the yellow may not exactly match, isn't really a problem.

11
  • Hi! Thank you for your answer! I thought about simply using yellow as canvas background colour. Unfortunately, the yellow border is not uniform in its colour. So if I choose a single yellow colour as canvas background, the transition might be perfect at the top, but not at the sides and bottom. In addition, the yellow border colour varies between images I want to batch-process. So in addition to variations within the images, there are variations of the yellow colour between images. For this reason I chose content aware, as this procedure can adapt to local changes in the yellow colour.
    – Jo Brick
    Apr 5 at 18:34
  • @JoBrick Okay.. then I believe you need at least part of the yellow contained within the selection you make. Content Aware is going to be restricted to the selection if there's no yellow in the selection, it won't see it. Perhaps expand/contract the selection a bit after making it. Or, use the Border option if you know the pixels width you need.
    – Scott
    Apr 5 at 18:40
  • If I only process a single image, the content-aware filling works. I select the white empty area as area which is supposed to be filled. Afterwards, Photoshop asks me to select the "reference area" called "custom sampling area" using the "sampling brush tool". I indicated the selected sampling area in pink. This is basically what teaches the algorithm how to fill the white empty area in a "content-aware" manner. If I do this only for 1 image, it works and the result is what I designated as "expected result". If I perform this in batch automation, then the last filling step fails.
    – Jo Brick
    Apr 5 at 18:43
  • I just saw your new comment. I will try to include some yellow into my selection! This is a good idea! I will report back how it works!
    – Jo Brick
    Apr 5 at 18:45
  • Perhaps you need the user interaction step for that part of the action (if you don't have it set already). But that means you'll need to do that for batch image, making the "batch" less useful.
    – Scott
    Apr 5 at 18:45
0

You already have a good answer from @Scott which shows what is probably the sane thing to do. But I'll try to show how you could automatize using Content-Aware Fill to expand a border around an image. In this case, it's probably not needed, but you could be dealing with images which actually had some texture worth preserving in the border.

I know from your other question about Pokémon cards what your end goal is, so I'll put in a few extra steps that will help you create an image which not only has an extended border, but also has the right physical dimensions (63×88 mm).

First you have to manually select the border. In your particular case it seems to work using Magic Wand tool with Sample Size set to *3 by 3 Average" and Tolerance set to 20 (Anti-alias and Contiguous ticked on).

With other kinds of images (like drawings) you might have to use Rectangular Marquee Tool, Quick Selection Tool or perhaps even Object Selection Tool or Select > Subject.

We'll assume you that your images are flattened and that you've clicked the yellow border with Magic Wand with the mentioned settings. Then you can start recording an action in the Actions panel. (It's a long recipe, so I won't go into every detail.)

  1. Convert the Background Layer to a Smart Object.
    This is done to protect the image from getting cropped.

  2. Perform Select > Inverse.

  3. Perform Select > Modify > Contract and contract by 4 px.
    This is done to make sure you don't have any stray pixels selected. Won't work if they have a radius larger than 4 px.

  4. Perform Select > Modify > Expand and expand by 3 px.
    This is done to get back to the same "bounding box" as before, but 1 px smaller to crop it a tiny bit tighter.

  5. Perform Image > Crop.

  6. Enter Image > Image Size. Untick Resample. Input the physical width of the printed rectangle in the Width field. Press OK.
    I'm guessing the width could be 57 mm, but you should try to check that. This is done to automatically adjust the resolution of the image so the image "knows" its own size. Later you can then scale the image simply by entering the wanted resolution as you know once and for all that the dimensions are correct. Or rather as correct as possible with these low res scans.

  7. Make a Layer Mask on the layer with the current selection.
    This is done to save the selection for later use.

  8. Enter Image > Canvas Size. Make sure Relative is unticked. Anchor is in the center. In the Width and Height fields, input the correct physical size including bleed.
    Pokémon cards should be 63×88 mm, so with 3 mm bleed you get 69×94 mm.

  9. Duplicate the layer.

  10. Select the Layer Mask of the duplicate layer.

  11. Invert the Layer Mask of the duplicate layer using Ctrl /Cmd + I.

  12. Rasterize the duplicate layer.

  13. Select the Layer Mask of the duplicate.

  14. Apply the Layer Mask of the duplicate layer.
    This deletes everything from the layer, but the border, making it easy to fill it with Content-Aware Fill without any pollution from the rest of the image.

  15. Select the opacity of the duplicate layer by Ctrl /Cmd-clicking its thumbnail.

  16. Perform Select > Inverse.

  17. Perform Select > Modify > Expand and expand by 2 px.
    This is done to in case there is a 1-2 px border on the border.

  18. Perform Edit > Content-Aware Fill. Use the default settings and set Output To to Current Layer.

  19. Move the duplicate layer below the original layer.

  20. Select the Layer Mask of the original layer.

  21. Delete the Layer Mask of the original layer.

  22. Perform Layer > Flatten Image.

  23. Perform Select > Deselect.

Phew, that was many steps, sorry. Perhaps it could be simplified a bit and perhaps you would want to tweak some of the values, but this is the main idea.

This is how it looks in action:

3
  • Thank you for this very elaborate answer. This is indeed amazing! For my project, it is probably sufficient to replace the complete border and fill it with one selected yellow colour. But your approach is highly relevant if there is a similar problem where the texture in the border needs to be maintained. It looks complicated at first, but following the steps one by one it is quite easy to do, and it's amazing that this procedure can be automated. I am also highly amazed by these gifs illustrating the workflow.
    – Jo Brick
    Apr 6 at 9:13
  • Yesterday, I already accepted the answer of Scott. It is a shame I can't accept two answers. And as I am a new member, I can't upvote your post. But I would like to express my gratitude for working out and sharing this solution. Thank you very much!
    – Jo Brick
    Apr 6 at 9:16
  • You are very welcome. 😀 I was eager to show this solution. Don't worry about the upvote. Not everything can be done in 3 steps. So this took 23 steps, but many things we do take many steps. We just don't normally write them down. It can be reused, so I think it's worth it. I also wanted to show you how it's easy to get the scale right by simply cropping to a known width and entering the dimensions. (Btw: The gif is made with ScreenToGif).
    – Wolff
    Apr 6 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.