@@ -50,7 +50,7 @@ function grdimage(cmd0::String="", arg1=nothing, arg2=nothing, arg3=nothing; fir
5050 (! haskey (d, :R ) && any (startswith .(cmd0, [" @earth_" , " @mars_" , " @pluto_" , " @moon_" , " @venus_" ]))) &&
5151 (CTRL. limits[1 : 4 ] = CTRL. limits[7 : 10 ] = [- 180 , 180 , - 90 , 90 ])
5252
53- if (arg1 === nothing && haskey ( d, :R ) && guess_T_from_ext (cmd0) == " -Ti" )
53+ if (arg1 === nothing && ( get ( d, :R , nothing ) != = nothing ) && guess_T_from_ext (cmd0) == " -Ti" )
5454 _opt_R = d[:R ]
5555 t = (isa (_opt_R, Tuple) || isa (_opt_R, VMr)) ?
5656 [" $(_opt_R[1 ]) " , " $(_opt_R[2 ]) " , " $(_opt_R[3 ]) " , " $(_opt_R[4 ]) " ] : split (_opt_R, ' /' )
7777function _grdimage (cmd0:: String , arg1, arg2, arg3, O:: Bool , K:: Bool , d:: Dict )
7878
7979 arg4 = nothing # For the r,g,b + intensity case
80- #=
81- common_insert_R!(d, O, cmd0, arg1) # Set -R in 'd' out of grid/images (with coords) if limits was not used
82-
83- # Remote files with no -R are all global. Set CTRL.limits so we can guess the projection.
84- (!haskey(d, :R) && any(startswith.(cmd0, ["@earth_", "@mars_", "@pluto_", "@moon_", "@venus_"]))) &&
85- (CTRL.limits[1:4] = CTRL.limits[7:10] = [-180, 180, -90, 90])
86-
87- if (arg1 === nothing && haskey(d, :R) && guess_T_from_ext(cmd0) == " -Ti")
88- _opt_R = d[:R]
89- t = (isa(_opt_R, Tuple) || isa(_opt_R, VMr)) ?
90- ["$(_opt_R[1])", "$(_opt_R[2])", "$(_opt_R[3])", "$(_opt_R[4])"] : split(_opt_R, '/')
91- opts = ["-projwin", t[1], t[4], t[2], t[3]] # -projwin <ulx> <uly> <lrx> <lry>
92- arg1 = cut_with_gdal(cmd0, opts)
93- cmd0 = ""
94- end
95- =#
9680
9781 # Prevent that J=guess is applied to a non-geog grid/image
9882 (arg1 != = nothing && (symb = is_in_dict (d, [:proj :projection ])) != = nothing && (d[symb] == " guess" || d[symb] == :guess ) && ! isgeog (arg1)) &&
@@ -102,8 +86,11 @@ function _grdimage(cmd0::String, arg1, arg2, arg3, O::Bool, K::Bool, d::Dict)
10286 (is_in_dict (d, [:A :img_out :image_out ]) != = nothing ) && (d[:B ] = " none" ) # When -A is used, -B is forbiden
10387 cmd:: String , opt_B:: String , opt_J:: String , opt_R:: String = parse_BJR (d, " " , " " , O, " -JX" * split (DEF_FIG_SIZE, ' /' )[1 ] * " /0" )
10488 (startswith (opt_J, " -JX" ) && ! contains (opt_J, " /" )) && (cmd = replace (cmd, opt_J => opt_J * " /0" )) # When sub-regions
105- (! has_opt_B && isa (arg1, GMTimage) && (isimgsize (arg1) || CTRL. limits[1 : 4 ] == zeros (4 )) && opt_B == DEF_FIG_AXES_BAK) &&
106- (cmd = replace (cmd, opt_B => " " )) # Dont plot axes for plain images if that was not required
89+ sim = (! has_opt_B && isa (arg1, GMTimage) && (isimgsize (arg1) || CTRL. limits[1 : 4 ] == zeros (4 )) && opt_B == DEF_FIG_AXES_BAK)
90+ if (! sim && cmd0 != = " " && ! has_opt_B)
91+ sim = (lowercase (splitext (cmd0)[2 ]) in [" .jpg" , " .jpeg" , " .png" , " .bmp" , " .webp" ])
92+ end
93+ sim && (cmd = replace (cmd, opt_B => " " ))
10794
10895 cmd, = parse_common_opts (d, cmd, [:UVXY :params :margin :c :f :n :p :t ]; first= ! O)
10996 cmd = parse_these_opts (cmd, d, [[:A :img_out :image_out ], [:D :img_in :image_in ], [:E :dpi ], [:G :bit_color ],
@@ -122,21 +109,6 @@ function _grdimage(cmd0::String, arg1, arg2, arg3, O::Bool, K::Bool, d::Dict)
122109 end
123110 end
124111
125- #=
126- if (isa(arg1, Matrix{<:Real}) || isa(arg1, Array{<:Real,3}))
127- if (isa(arg1, Matrix{UInt8}) || isa(arg1, Matrix{UInt16}) || isa(arg1, Array{UInt8,3}))
128- arg1 = mat2img(arg1; d...)
129- else
130- arg1 = mat2grid(arg1)
131- (isa(arg2, Matrix{<:Real})) && (arg2 = mat2grid(arg2))
132- (isa(arg3, Matrix{<:Real})) && (arg3 = mat2grid(arg3))
133- end
134- elseif (isa(arg1, GMTimage) && size(arg1, 3) <= 3 && eltype(arg1.image) <: UInt16)
135- arg1 = mat2img(arg1; d...)
136- (haskey(d, :stretch) || haskey(d, :histo_bounds)) && delete!(d, [:histo_bounds, :stretch])
137- end
138- =#
139-
140112 set_defcpt! (d, cmd0, arg1) # When dealing with a remote grid assign it a default CPT
141113 (isa (arg1, GMTgrid) && arg1. cpt != " " ) && (d[:this_cpt ] = arg1. cpt)
142114 (haskey (d, :this_cpt ) && isfile (d[:this_cpt ])) && (CURRENT_CPT[] = gmtread (d[:this_cpt ]))
0 commit comments