Psxy: transparenсy attempt faults

Dear developers
i want to clear some details on map using polygone with default transperance color.
(gmt 5.4.5 Windows 7/10)
echo 18.22 49.10>europe.gmt
echo 19.16 49.89>>europe.gmt
echo 18.04 49.91>>europe.gmt
echo 18.22 49.10>>europe.gmt

psxy -Jx1.5d/1.5d -R10/25/40/55 europe.gmt -G255/255/255 -K >
pscoast -R -J -Di -N1/blue -W1p,black -B5g5/5g5 -A4000 -O >>
gswin64c -sDEVICE=png256 -dNOPLATFONTS -dNOPAUSE -dSAFER -sOutputFile=image1.png –
gswin64c -sDEVICE=pngalpha -dBackgroundColor=16#ffffff -dNOPAUSE -dSAFER -sOutputFile=image2.png –

It looks like ghostscript does not recognized white background in my poligone

I can save in png256 and set white as color of transparence, but it will be so fine to skip this.

Why is this assignment not working as expected? What needs to be done to get the correct result?

Thanx for any advice



Allow me to be honest. Every time I see a question and GMT5… I more or less loose interest in the question. If users don’t wan to bother to update and see if the problem was solved meanwhile, why should we care?

Sorry, i understend my fault. I’ll try to be more specific
My goal is to draw an administrative boundary from DCW and remove some small details. But coast -A parameter removes only coastline objects.
I updated ghostscript to 10.00 and use GMT 6.3.0
It’s my new codes and the result. It’s not changed

    set rj=-Jx4.d/4.d -R26.5/29/59/61
gmt begin eu ps
  gmt set PS_PAGE_COLOR 255/255/255 MAP_FRAME_TYPE inside
  gmt plot %rj% len.gmt -G255/255/255
  gmt coast %rj% -Di -W1p,black -ERU.LEN+p.5,blue -BWESN -Ba2.5f1g1 -A4000
gmt end

gswin64c -sDEVICE=pngalpha -dBackgroundColor=16#ffffff -dNOPAUSE -dSAFER -sOutputFile=image2.png -- >>nul:

Are there other methods to remove the islands from the Gulf of Finland?

P.S. I tried to use the search, but I could not find anything suitable

Mmm, I think you could use gmt select.

Why GMT6.3.0 and not the latest GMT6.4.0?
Anyway Gostscript10 introduced a new bug in GMT regarding transparency. Options are: downgrade GS to or use a the GMT developer version. For Windows you can use this

Other thing. Use psconvert instead of calling gswin64c directly.

Many thanks, Joaquim for your generous help. I’ve tried

  • 6.5.0 GMT version
  • previous GS version (9.55)
  • pcconvert (>gmt psconvert -GC:\tools\gs\gsx.xx\bin\gswin64c -A -TG)

Unfortunately still no changes. It was expected and it was initially the bad idea :frowning:
untouched regions are transparent” as it written in docs.

Then I’ve got two other questions: it is possible in begin sentence

  • to output indexed raster (8-bits) file (bmp256/png256)?
  • to set pngalpha format (and BackgroundColor color)?
    gmt begin eu png TG or C-sDEVICE=png256 or C-dBackgroundColor=16#ffffff not works
    gmt psconvert -Tg -C-sDEVICE=png256 not works too

If you installed ghostscript via installer you don’t need the -G option above.

Regarding the rest

I’m sorry but I’m a bit lost of what does not work. Can you produce a minimal example that we can reproduce?

Joaquim , thank you once again
I found Caspian sea boader in DCW 6th version. It was my another headache.

I’m using -G for testing different GS versions

i’ve trouble with GMT 6th version In conjunction with Powershell

Regarding the rest
i found in docs that my problem has no solution.
Maybe, “for general education”. What is the reason for the restriction “untouched regions are transparent”. It is possible to assign control of transparency, to assign transparency to a specific color.

Sorry to worried you. But you really helped

as to GMT psconvert. It’s easy

It was my attempt to use psconvert with my option - 8-bit png output file.
Canonnical GS code uses -sDEVICE to set the indexed format (gswin64c -sDEVICE=png256 …)
So i used -C parameter psconvert (GS_option) to pass it on to GS
psconvert -C-sDEVICE=png256

but output png file still has truecolor data. I belive that psconvert can’t convert any PS file to 8-bit indexed png file

Hi Alexander, if I understand you right you would like to plot some polygons on top of other things and assign the color of those polygons to be transparent. This would basically punch a hole in the plot in those polygons as the PNG will be transparent there. Is that what you want? I did an experiment of plotting a red square and then overlaying a smaller yellow at 100% transparency and of course all we get is the red square. So that is how it works. I think post-processing of an image might be simpler.

Yes, GMT doesn’t work well in powershell. We don’t know why, but it should be equal for both GMT 5 & 6.

Please, you have to help us more. I still didn’t understand what is your problem. And yes, sure we can assign a color with transparency. Gallery has one such example.

… I’m seeing that Paul also replied and probably understood your issue better than me but I’ll send my questions.

Hi, Paul,
Hi, Joaquim

That’s all i want to get. The final image consists of the coastline and administrative boundaries. The image must be salted over another image in the web page. The image on the page is like a layered cake made up of layers of different information. This one and all is similar to a GIS application.

And yes, i made a post-processing sequence with nconvert (xnview)

Thank you all
Maybe the topic can be closed

There’s a new trouble in PS_MEDIA WxH parameter in GMT 6th version. I think this theme deserves a separate thread.

Another thought: if you plot your polygons first with psclip then those areas will be untouched and hence transparent

So you want to plot a donut shape polygon? If so, you have to pre process your data with gmt spatial -Sb.

Hi, Esteban
You offer a working and popular solution, thank you.
I chose post-processing. it’s is more versatile, simply and good looking for me. This crutch came useful