if your images are stored in docker hub, you can hit the "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=25" endpoint and fetch all the details of your image.
e.g if i do a curl -s https://hub.docker.com/v2/repositories/library/hello-world/tags i get a response like:
{
"count": 9,
"next": "https://hub.docker.com/v2/repositories/library/hello-world/tags/?page=2&page_size=2",
"previous": null,
"results": [
{
"creator": 1156886,
"id": 164125618,
"image_id": null,
"images": [
{
"architecture": "amd64",
"features": "",
"variant": null,
"digest": "sha256:71ca70650c09da31487c1dfb348bf780c8807b9617974180eaaed46381e82ab0",
"os": "windows",
"os_features": "",
"os_version": "10.0.20348.169",
"size": 117982763,
"status": "active",
"last_pulled": "2021-08-25T08:46:14.795809Z",
"last_pushed": "2021-08-24T23:43:26.950422Z"
}
],
"last_updated": "2021-08-24T23:43:53.833792Z",
"last_updater": 1156886,
"last_updater_username": "doijanky",
"name": "nanoserver-ltsc2022",
"repository": 31760,
"full_size": 117982763,
"v2": true,
"tag_status": "active",
"tag_last_pulled": "2021-08-25T08:46:14.795809Z",
"tag_last_pushed": "2021-08-24T23:43:53.833792Z"
},
{
"creator": 2215,
"id": 6273972,
"image_id": null,
"images": [
{
"architecture": "amd64",
"features": "",
"variant": null,
"digest": "sha256:07ec39351767b7d0453681761b5a7e1bbc98b71243ad5db8481af4700f7cc06e",
"os": "windows",
"os_features": "",
"os_version": "10.0.17763.2114",
"size": 102744045,
"status": "active",
"last_pulled": "2021-08-25T08:46:14.915481Z",
"last_pushed": "2021-08-24T21:42:07.39618Z"
},
{
"architecture": "amd64",
"features": "",
"variant": null,
"digest": "sha256:71ca70650c09da31487c1dfb348bf780c8807b9617974180eaaed46381e82ab0",
"os": "windows",
"os_features": "",
"os_version": "10.0.20348.169",
"size": 117982763,
"status": "active",
"last_pulled": "2021-08-25T08:46:14.795809Z",
"last_pushed": "2021-08-24T23:43:26.950422Z"
}
],
"last_updated": "2021-08-24T23:43:47.337855Z",
"last_updater": 1156886,
"last_updater_username": "doijanky",
"name": "nanoserver",
"repository": 31760,
"full_size": 117982763,
"v2": true,
"tag_status": "active",
"tag_last_pulled": "2021-08-25T08:46:14.915481Z",
"tag_last_pushed": "2021-08-24T23:43:47.337855Z"
}
]
}
Now, you should be able to filter out any two images from the results array using some info (name/tag/hash/date) and subtract the sizes between the two. In your case, the one you have locally and the one you will be pulling (i.e the latest one). The size difference should give you an idea on how much data will be fetched if you pull the modified layer.
Also, check out the official documentation of the docker hub api: Here