1

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

  • Adobe solution would be a Droplet, alternative method would be to use Imagemagick – Ryan Jan 6 '16 at 12:52
  • Hi Prasanth, welcome to GDSE! It would appear you have accidentally created multiple accounts. Stack Exchange only allows one account per user on a site. Please go to our help section and contact SE to have this issue fixed. – Vincent Jan 8 '16 at 11:23
1

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:

enter image description here

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:

enter image description here

The result is this:

enter image description here

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.

0

I've found a way to do this using imagemagick

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

  • HI G Prashanth, welcome to GD.SE and thanks for your input! Please, do not use the answer field for comments or reaction to other posts, that's what comments are for. Once your reputation is sufficient (30), you can comment everywhere. If you have any questions about the site, have a look at the help center. Keep contributing and enjoy the site! – Vincent Jan 8 '16 at 11:21

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.