Helioviewer-Project / helioviewer.org

Main web application for solar data visualization
Other
19 stars 15 forks source link

Cut out service sends bad API requests when selection is not on the sun #370

Open dgarciabriseno opened 2 years ago

dgarciabriseno commented 2 years ago

Request

api.helioviewer.org/?action=takeScreenshot&imageScale=18.531484375&layers=[13,1,100]&events=&eventLabels=false&scale=false&scaleType=earth&scaleX=0&scaleY=0&date=2022/07/26T13:36:05Z&x1=2372&x2=7116&y1=4332&y2=4579&display=true&watermark=false

Result

negative or zero image size `/data/cache/helioviewer.org/screenshots/2022/07/26/26747558/2022/07/408751064149917063.pgm' @ error/pnm.c/ReadPNMImage/443
dgarciabriseno commented 2 years ago

Following the trail on this. I found that kdu_expand is expanding the images down to nothing... From my local testing so far: 11998945421549118743.pgm: Netpbm image data, size = 0 x 0, rawbits, greymap When attempting to load this into image magick, I get the above error. Need to follow the parameters to see what's getting passed to kdu_expand

dgarciabriseno commented 2 years ago

Yep, getting this for "{<top>,<left>},{<height>,<width>}" {2.2353,1.4504},{0,0}

Following how these arguments are computed.

dgarciabriseno commented 2 years ago
x1=2372
y1=7116
x2=7116
y2=4579

The above region is passed to the API. This region at imageScale 18 for source 13 (AIA 304) is just black space.

I think these are coming from the cut-out service in the UI because that seem to be where the takeScreenshot requests with the scales set to 0 and display=true come from.

It seems to me this error is completely valid since the front end is sending bogus requests.

dgarciabriseno commented 2 years ago

Ideally the front end shouldn't send any API request if the selection is out of bounds. It handles out-of-bounds for taking screenshots, but not for the Cut out service as shown below.

image
dgarciabriseno commented 1 year ago

We should use the onerror attribute of the image tags to update these to some default "no data" image.

onerror="this.src='something else'"