3
3
"""
4
4
import base64
5
5
import os
6
+ import warnings
6
7
from tempfile import TemporaryDirectory
7
8
8
9
try :
@@ -129,13 +130,14 @@ def region(self):
129
130
C = "gs_option" ,
130
131
E = "dpi" ,
131
132
F = "prefix" ,
132
- I = "icc_gray" ,
133
+ I = "resize" ,
134
+ N = "bb_style" ,
133
135
T = "fmt" ,
134
136
Q = "anti_aliasing" ,
135
137
V = "verbose" ,
136
138
)
137
139
@kwargs_to_strings ()
138
- def psconvert (self , ** kwargs ):
140
+ def psconvert (self , icc_gray = False , ** kwargs ):
139
141
r"""
140
142
Convert [E]PS file(s) to other formats.
141
143
@@ -153,9 +155,14 @@ def psconvert(self, **kwargs):
153
155
Parameters
154
156
----------
155
157
crop : str or bool
156
- Adjust the BoundingBox and HiResBoundingBox to the minimum required
157
- by the image content. Append ``u`` to first remove any GMT-produced
158
- time-stamps. Default is True.
158
+ Adjust the BoundingBox and HiResBoundingBox to the minimum
159
+ required by the image content. Default is True. Append **+u** to
160
+ first remove any GMT-produced time-stamps. Append **+r** to
161
+ *round* the HighResBoundingBox instead of using the ``ceil``
162
+ function. This is going against Adobe Law but can be useful when
163
+ creating very small images where the difference of one pixel
164
+ might matter. If ``verbose`` is used we also report the
165
+ dimensions of the final illustration.
159
166
gs_option : str
160
167
Specify a single, custom option that will be passed on to
161
168
GhostScript as is.
@@ -167,8 +174,33 @@ def psconvert(self, **kwargs):
167
174
using the input names as base, which are appended with an
168
175
appropriate extension. Use this option to provide a different name,
169
176
but without extension. Extension is still determined automatically.
170
- icc_gray : bool
171
- Enforce gray-shades by using ICC profiles.
177
+ resize : str
178
+ [**+m**\ *margins*][**+s**\ [**m**]\ *width*\
179
+ [/\ *height*]][**+S**\ *scale*] ].
180
+ Adjust the BoundingBox and HiResBoundingBox by scaling and/or
181
+ adding margins. Append **+m** to specify extra margins to extend
182
+ the bounding box. Give either one (uniform), two (x and y) or four
183
+ (individual sides) margins; append unit [Default is set by
184
+ :term:`PROJ_LENGTH_UNIT`]. Append **+s**\ *width* to resize the
185
+ output image to exactly *width* units. The default unit is set
186
+ by :term:`PROJ_LENGTH_UNIT` but you can append a new unit and/or
187
+ impose different width and height (**Note**: This may change the
188
+ image aspect ratio). What happens here is that Ghostscript will do
189
+ the re-interpolation work and the final image will retain the DPI
190
+ resolution set by ``dpi``. Append **+sm** to set a maximum size
191
+ and the new *width* is only imposed if the original figure width
192
+ exceeds it. Append /\ *height* to also impose a maximum height in
193
+ addition to the width. Alternatively, append **+S**\ *scale* to
194
+ scale the image by a constant factor.
195
+ bb_style : str
196
+ Set optional BoundingBox fill color, fading, or draw the outline
197
+ of the BoundingBox. Append **+f**\ *fade* to fade the entire plot
198
+ towards black (100%) [no fading, 0]. Append **+g** \*paint* to
199
+ paint the BoundingBox behind the illustration and append **+p**\
200
+ [*pen*] to draw the BoundingBox outline (append a pen or accept
201
+ the default pen of 0.25p,black). Note: If both **+g** and **+f**
202
+ are used then we use paint as the fade color instead of black.
203
+ Append **+i** to enforce gray-shades by using ICC profiles.
172
204
anti_aliasing : str
173
205
[**g**\|\ **p**\|\ **t**\][**1**\|\ **2**\|\ **4**].
174
206
Set the anti-aliasing options for **g**\ raphics or **t**\ ext.
@@ -192,6 +224,18 @@ def psconvert(self, **kwargs):
192
224
# Default cropping the figure to True
193
225
if "A" not in kwargs :
194
226
kwargs ["A" ] = ""
227
+
228
+ if icc_gray :
229
+ msg = (
230
+ "The 'icc_gray' parameter has been deprecated since v0.6.0"
231
+ " and will be removed in v0.8.0."
232
+ )
233
+ warnings .warn (msg , category = FutureWarning , stacklevel = 2 )
234
+ if "N" not in kwargs :
235
+ kwargs ["N" ] = "+i"
236
+ else :
237
+ kwargs ["N" ] += "+i"
238
+
195
239
# Manually handle prefix -F argument so spaces aren't converted to \040
196
240
# by build_arg_string function. For more information, see
197
241
# https://github.com/GenericMappingTools/pygmt/pull/1487
0 commit comments