Skip to main content
Participant
June 16, 2017
Answered

Scripting: Batch selecting/deleting background

  • June 16, 2017
  • 2 replies
  • 5955 views

Hello, I'm trying to write a JS script for Photoshop CS unfortunately I'm very new to js and can't find a way to solve it.

I have a batch of image files with a background that I want to delete/ or set white. Sample images below.

I do it manually with a 'quick selection tool'. I select the tool, press left button in the left top corner and move it right-down-left-top which selects the background. Right click and now I create a new layer via cutting which splits the background and the main picture. I delete the background and save the picture in a different folder.

I tried action manager but it doesnt record everything and it cant select the background.

Thank you for your help

This topic has been closed for replies.
Correct answer morb82035406

Dear JJMack, thank you for your interest.

Yes, that was a poor choice of the images for the example - Dylan Dog looses image data, an error I accept. I'll correct it manually. Unfortunately I don't know how masks work.

I was ambiguous, I want to delete background and/or change it to pure white/other color or just leave it and save it as transparent. Saving it as transparent should work fine /white background jpg is also ok/

Unfortunately if you are not experience in scripting you won't be able to help me. I need it done not done better, unfortunately.

2 replies

Participant
June 19, 2017

anyone else with scripting experience?

/ I don't know why this guy cropped both pictures befor using 'quick selection tool'. I want to select/delete background not crop the picture/

JJMack
Community Expert
Community Expert
June 19, 2017

Your Way Layer Via Cut Delete layer You will loose image data,masking will not.

JJMack
JJMack
Community Expert
Community Expert
June 21, 2017

Dear JJMack, thank you for your interest.

Yes, that was a poor choice of the images for the example - Dylan Dog looses image data, an error I accept. I'll correct it manually. Unfortunately I don't know how masks work.

I was ambiguous, I want to delete background and/or change it to pure white/other color or just leave it and save it as transparent. Saving it as transparent should work fine /white background jpg is also ok/

Unfortunately if you are not experience in scripting you won't be able to help me. I need it done not done better, unfortunately.


Scripting it would have the same results as the action. That script may even need to use to use some action manager code.  The Actions I posted can  be converted into a script with xtools or could have been recorded as a script in the first place using Adobe's  Scriptlistened plug-in.  A script does not change what Photoshop can do.

Your examples show clearly show you method can not remove backgrounds.  There is no single method that can remove all backgrounds.  Adobe extract plugin was so bad Adobe removed. If a method was possible Photoshop would have it as a feature.  Photoshop does have tools and features that can help you remove some backgrounds. Some Backgrounds are impossible to remove. You do have a lot to learn.

If a method was possible I could most likely hack it in a Photoshop Script.  I know quits a bit about what a script can do and can not do.  A script can not do what is not possible to do with Photoshop.  If Photoshop can remove and image's background a script to do the same may not be possible for the most powerful tool you have using Photoshop can not be put in a script. The gray matter between your ears can not be transplanted into a script.

The second Action in the action set I posted does your exact method. You method simply does not work not single method is possibly.

JJMack
JJMack
Community Expert
Community Expert
June 16, 2017

morb82035406  wrote

Hello, I'm trying to write a JS script for Photoshop CS unfortunately I'm very new to js and can't find a way to solve it.

I have a batch of image files with a background that I want to delete/ or set white. Sample images below.

I do it manually with a 'quick selection tool'. I select the tool, press left button in the left top corner and move it right-down-left-top which selects the background. Right click and now I create a new layer via cutting which splits the background and the main picture. I delete the background and save the picture in a different folder.

I tried action manager but it doesnt record everything and it cant select the background.

What you wrote above is pure fiction from your imagination.  The example you show  is science fiction.  Two different images with different Aspect ratio size and content. Not a single image example of with and without  a background.

You also can not select the background in either of those images with the manual  method you write you do it with. If that method did work you could record it in an action. You would need to enable tool recording while recording the action.  However, the action would only work on other documents that are the same size and resolution as the document you recorder the action with.  Other size document the tools recording will not work correctly.  

Before you can BS about Photoshop you should learn Photoshop perhaps then you can make your fiction believable.

Your manual method makes these selections

JJMack