Mobile app version of vmapp.org
Login or Join
Eichhorn212

: Making background transparent without changing filename I've folders containing png images of map tiles to be overlayed on google maps, created using QTiles plugin in QGIS. I want to remove the

@Eichhorn212

Posted in: #BackgroundRemoval #BatchProcessing #Tiles #Transparency

I've folders containing png images of map tiles to be overlayed on google maps, created using QTiles plugin in QGIS. I want to remove the white background of all the tiles so that base map is properly visible. Names of folders and files should not be changed as they represent zoom levels and position of the tiles. Can you please suggest how this can be done? Thanks

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Eichhorn212

2 Comments

Sorted by latest first Latest Oldest Best

 

@Shanna688

I've found a way to do this using imagemagick

for /R %f in (*.png) do mogrify -format png –transparent white *.png

10% popularity Vote Up Vote Down


 

@Jennifer810

To do this you will have to manually edit 1 image. In doing so you will set up a new action (assuming you have Photoshop).

Take your first image and open it in Photoshop.

From there, if the actions panel is not visible, click at the top "window" > "Actions"

At the bottom of the actions panel select "Create New Action" Name the Action I named mine "Remove White BG". Then Hit Record. See below:



Now it is recording (You can tell by the red circle in the actions panel).

I had some trouble opening PNG's so the first step in your action should be to convert to RGB (In my case this makes the PNG editable).

Then Click the lock located on your current layer to unlock it.

From there click "Select" > "Color Range" Then using the eye dropper select the white background. (Depending on the quality/contrast of the image this should be fairly simple, but could require some finesse to get the entire background selected). I chose a black and white image (and increased the fuzziness to 200% to select any loose "off-white" pixels). See below:



The result is this:



Now your Action is ready to be utilized in the batching process.

Go to "File" > "Automate" > "Batch"

At the top of the window select the action you just made.

Choose your start folder (the folder your PNG's are located in).

Choose a Destination folder (this can temporary, so you can eventually replace your current PNG's)

In the File Naming Section. make sure the first line says "document name" and the second line says "extension" (this will ensure your naming stays the same).

Edit any other settings that may interest you and hit OK.

Like I said earlier this will work very well for images with a plain background that contrasts the foreground, the more complex the image the harder it will be to batch them all. Good luck.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme