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

Remove ALL white that is JUST in the BG of an BW PNG image

Contributor ,
Oct 19, 2021 Oct 19, 2021

Hello.

 

I have +5000 black and white PNG images with black drawings (mandalas) on them that have square dimensions but the image it self is not squared.

I need batch action that will:
a) Select all white around using magic wand
b) Invert selection
c) Crop image to selection
d) Change dimensions to 3000×3000px
e) Save as PNG transparent with 300px (the original is 300px)

Problems I am facing: 
- if mandala in original photo is touching the edge the magic wand only selects one corner of white. I hoped I can make multiple magic wand clicks in to action but it is not working. 

- save as PNG for some strange reason changes resolution to 96px

Windows 10 PC
Photoshop 22.5.1.441 (others have bugs, artboard is not transparent even if both settings are checked)

I tried using these:

 

and

I do not understand this one:
With Photoshop, how to batch replace white background with transparent in the image

 

and how to convert from tiff to PNG at the end. Why export to PNG is not acceptable?


mandala issue.png40.png

TOPICS
Actions and scripting
8.7K
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
Contributor ,
Oct 19, 2021 Oct 19, 2021

Thank you. Can you point me to the service store where I can hire someone to make this action for me start to end and that it works? I also need similar action to work in Illustrator Remove white from BW but keep the inside white SVG/AI
If I could hire someone to make these two actions that would help.
I do not use Photoshop on daily bases, just to batch process 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
LEGEND ,
Oct 19, 2021 Oct 19, 2021

These forums are not really intended to be job boards, so it would need to be a different website.

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 ,
Oct 19, 2021 Oct 19, 2021

OK. Should I continue to wait here until someone makes the working action I need, start to end? What is your reccomendation? 

I tried running the above actions on all kinds of photos and it always gets stuck on the magic wand set and make. 

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
LEGEND ,
Oct 19, 2021 Oct 19, 2021

Maybe you could experiment with recording some actions yourself to see if you can get it to work?

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 ,
Oct 19, 2021 Oct 19, 2021

Actions are easy to record. Try to record some yourself. To use the magic wand you need to target the layer so it's best to flatten or merge all layers together so there is just a single layer and make it a normal layer. Set your Photoshop Preferences to Percentage so the magic wand will be recorded relatively to canvas size. Once you have the selection, expand it a few pixles to ensure the selection is trimming the subject well. Here is an example Action. It does many magic wand additions to try to get all the background white. It would be easier to kill all the white.


Use this link to download the action. If the link does not work when you click on it, copy and paste it into your browser address area or right click and use save link as.

 

bg.atn

JJMack
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 ,
Oct 19, 2021 Oct 19, 2021

@JJMack @Lumigraphics 
Yes, I understand. As I said I do not use Photoshop to that extend I am familirazied with solving problems in actions. I created actions and I constantly get errors in select, delete, make or save as steps.
@JJMack Thank you for the action, I will test it and report back.

I asked same question in paint.net forum and I got this so if anyone in the future come to this post with same problem/need/question and there is still no working action for Photoshop:


a) Install ImageMagick C:\Program Files\ImageMagick-7.1.0-Q16-HDRI
b) Copy and save in Notepad with BAT extension this code:
@echo off
SET /p TOLERANCE="Tolerance (Default: 20): " || SET "TOLERANCE=20"
SET /p MAGICKDIR="ImageMagick Directory (Default: C:\Program Files\ImageMagick-7.1.0-Q16-HDRI): " || SET "MAGICKDIR=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI"
SET /p POINT="Pick Color Point (Default: 0,0): " || SET "POINT=0,0"
SET /p INPUT_DIR="Input Directory: "
SET /p OUTPUT_DIR="Output Directory: "
@echo on
FOR %%a IN (%INPUT_DIR%\*.png) DO "%MAGICKDIR%\magick.exe" convert "%%~a" -gravity center -extent 105%%x105%% -fuzz %TOLERANCE%%% -fill transparent -draw "color %POINT% floodfill" -trim "%OUTPUT_DIR%\%%~nxa"
@echo "Done!"
PAUSE

c) Run the code

Marinapomorac_0-1634710911089.png

Images are cropped and transparent.

Second thing, resizing:
CODE FOR RESIZING (in this sample resizing is 3000×3000 and 300dpi)
@echo off
SET /p TOLERANCE="Tolerance (Default: 20): " || SET "TOLERANCE=20"
SET /p MAGICKDIR="ImageMagick Directory (Default: C:\Program Files\ImageMagick-7.1.0-Q16-HDRI): " || SET "MAGICKDIR=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI"
SET /p POINT="Pick Color Point (Default: 0,0): " || SET "POINT=0,0"
SET /p INPUT_DIR="Input Directory: "
SET /p OUTPUT_DIR="Output Directory: "
@echo on
FOR %%a IN (%INPUT_DIR%\*.png) DO "%MAGICKDIR%\magick.exe" convert "%%~a" ^
-background white ^
-gravity center ^
-extent 105%%x105%% ^
-fuzz %TOLERANCE%%% ^
-fill transparent ^
-draw "color %POINT% floodfill" ^
-trim ^
-units PixelsPerInch ^
-density 300 ^
-filter box ^
-resize 3000x3000 ^
-background transparent ^
-gravity center ^
-extent 3000x3000 ^
"%OUTPUT_DIR%\%%~nxa"
@echo "Done!"
@echo off
PAUSE

 

I was shocked to see that free program and couple of lines of code can do this on 300 photos under a minute. 

 

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
LEGEND ,
Oct 19, 2021 Oct 19, 2021

Could you link us to thread (on non-existing forum address) where you received above code?

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 ,
Oct 19, 2021 Oct 19, 2021

@Kukurykus 
Sure.
But why, is something wrong? 
Getpaint 

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
LEGEND ,
Oct 20, 2021 Oct 20, 2021

The name of url you mentioned didn't fully reflect website name so I couldn't find it, thx! 😉

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 ,
Oct 20, 2021 Oct 20, 2021

Oh, the Paint.NET? That is the name of the program not website or url.
I make same mistake when I am searching for plugins for it, and it gives me some random website. 

I am just used to typing it as it is called, I keep forgeting I should skip the dot. 

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 ,
Oct 20, 2021 Oct 20, 2021

If you want to automate the process you need to learn how to record acts even the Action I recorded for you will need to be edited for the save as step save to a folder on my desktop. You would need to edit the step to save to a folder on your machine,  The important part is when you edit the step you just change the folder. You do not touch  the file name field.  You want no name recorded into the action step.  That way Photoshop will default the name to be the current image name being processes by the action.  Usere here are trying to help you.

 

JJMack
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
LEGEND ,
Oct 20, 2021 Oct 20, 2021
LATEST

ImageMagick is widely used behind the scenes for websites and commercial graphics processing. It can't do everything Photoshop can do but is definitely powerful for batch processing.

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