GenericMappingTools / GenericMappingTools/gmt

Image is not cropped by `gmt end` via the API

Open
#4,518 11 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
979
Forks
414
Avg merge
17h 26m
Merged PRs (30d)
54

Description

The API can be used to create an image file with exactly the same instructions as a script. However, with or without the A option on the ``gmt begin`` line, the figure is not cropped when ``gmt end show`` is called.

Take this simple script:



gmt begin toto_script jpg
gmt basemap -BWESN -Bxa30mg30m -Bya20mg20m -JM7.27/42.27/16.25c -R5.5/41.425/9.0/43.1r
gmt end show

resulting in this image:

![toto_script](https://user-images.githubusercontent.com/44192622/100641501-d5e98180-3337-11eb-915f-61ff6c4da213.jpg)

The same instructions via the API:



int main () {
void *API;

/* Initialize the GMT session */
if ((API = GMT_Create_Session ("GMT_plot", 2, 0, NULL)) == NULL)
return EXIT_FAILURE;
GMT_Call_Module(API, "begin", GMT_MODULE_CMD, "toto_api jpg");
GMT_Call_Module(API, "basemap", GMT_MODULE_CMD, "-BWESN -Bxa30mg30m -Bya20mg20m -JM7.27/42.27/16.25c -R5.5/41.425/9.0/43.1r");
GMT_Call_Module(API, "end", GMT_MODULE_CMD, "show");
/* Destroy session */
if (GMT_Destroy_Session (API))
return EXIT_FAILURE;
}

produce a different image, not cropped:

![toto_api](https://user-images.githubusercontent.com/44192622/100641495-d550eb00-3337-11eb-9214-ec62ce570c6f.jpg)

Running ``gmt end show -Vd`` reveals the difference between script and API processing:

From script:
` end [DEBUG]: psconvert: '/home/sarzeaud/.gmt/sessions/gmt_session.14414/gmt_0.ps-' -Tj -Ftoto -A`
From C program (-A option is missing):
` end [DEBUG]: psconvert: '/home/sarzeaud/.gmt/sessions/gmt_session.14414/gmt_0.ps-' -Tj -Ftoto`

The result is the same whether or not we use the A option on the ``gmt begin`` line.

**System information**

* Operating system: Debian stretch
* GMT version (`gmt --version`): 6.2.0_d266c30_2020.11.25

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.