Skip to content

Commit fee9b12

Browse files
authored
Let psconvert -W+g switch to lossless PNG as intermediate format (#5968)
See #5807 for background. I changed my mind a bit and simply switch to PNG when -W+g is set and no -T is given. We then delete the unrequested PNG file at the end. This bypasses any lossy intermediate format.
1 parent a822060 commit fee9b12

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/psconvert.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,8 +985,9 @@ static int parse (struct GMT_CTRL *GMT, struct PSCONVERT_CTRL *Ctrl, struct GMT_
985985
Ctrl->H.active = false;
986986
}
987987

988-
if (!Ctrl->T.active) Ctrl->T.device = GS_DEV_JPG; /* Default output device if none is specified */
989-
988+
if (!Ctrl->T.active) { /* Set default output device if none is specified */
989+
Ctrl->T.device = (Ctrl->W.warp) ? GS_DEV_PNG : GS_DEV_JPG; /* Lossless PNG if we are making a geotiff in the end */
990+
}
990991
if (Ctrl->T.device > GS_DEV_SVG) { /* Raster output, apply default -Q for rasters unless already specified */
991992
/* For rasters, we should always add -Qt4 unless -Q was set manually. This will improve the rasterization of text */
992993
if (!Ctrl->Q.on[PSC_TEXT]) { /* Only override if not set */
@@ -2781,6 +2782,8 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
27812782
GMT_Report (API, GMT_MSG_ERROR, "System call [%s] returned error %d.\n", cmd, sys_retval);
27822783
Return (GMT_RUNTIME_ERROR);
27832784
}
2785+
if (!Ctrl->T.active) /* Get rid of the intermediate JPG file if -T was not set */
2786+
gmt_remove_file (GMT, out_file);
27842787
}
27852788
else if (Ctrl->W.warp && !proj4_cmd)
27862789
GMT_Report (API, GMT_MSG_ERROR, "Could not find the Proj4 command in the PS file. No conversion performed.\n");

0 commit comments

Comments
 (0)