Bug report #21962

JPG with Worldfiles shows black bounding box

Added by Roland Spielhofer 7 months ago. Updated 7 months ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Rasters
Affected QGIS version:3.6.2 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29777

Description

I have several JPGs together with JGW (worldfiles).
When I open them in QGIS 3.6.1 as Raster they show a black orthoganal bounding box while the image istself is shown rotated.
Comparison in ArcGIS: No black unrotated bounding box is shown.

Expected behaviour: Only rotated image is shown, no black boundingbox.

I attach a screenshot of side-by-side comparison on ArcGIS and QGis and a JPG image with according JGW worldfile to reproduce.
(The image shows road surface, do not mind that it shows only lots of shades of grey).

Worldfiles_JPG_QGis_ArcGis.jpg - Screenshot of side-by-side comparsion of QGis and ArcGis (252 KB) Roland Spielhofer, 2019-04-30 01:58 PM

A01L1_km146,178_km145,830___181109_1134_CRACK_tf1,029_0.jpg - JPG Image (1.89 MB) Roland Spielhofer, 2019-04-30 01:58 PM

A01L1_km146,178_km145,830___181109_1134_CRACK_tf1,029_0.jgw - According Worldfile (125 Bytes) Roland Spielhofer, 2019-04-30 01:59 PM

History

#1 Updated by Giovanni Manghi 7 months ago

  • Status changed from Open to Feedback

While I understand it can seem handy, why QGIS should make transparent the pixels with value 0,0,0 (the raster is RGB)? You can easily create a copy where 0,0,0 is nodata, and in this case QGIS (any GIS) will make those pixels "invisible".

#2 Updated by Roland Spielhofer 7 months ago

The black rectangles are not inherent in the data (raster). They come from the roatation caused by the world file (that rotation is done by QGis). I would say the comparison on the screenshot shows the problem quite clear.

#3 Updated by Giovanni Manghi 7 months ago

Roland Spielhofer wrote:

The black rectangles are not inherent in the data (raster). They come from the roatation caused by the world file (that rotation is done by QGis). I would say the comparison on the screenshot shows the problem quite clear.

the black areas are part of the raster, regardless of their origin. If those areas are pixels that are NOT defined as NODATA then they of course will show > you can make them transparent OR you can create copies of your raster where those pixels are transformed into NODATA.

This is not a bug, a feature request a maximum (an option to make transparent certain pixels on load?).

#4 Updated by Roland Spielhofer 7 months ago

When I click into the raster I see lower values for all channels the darker the pixels are.
Would define the values of "0" to NODATA not also make all "perfect black" pixels in the JPG transparent as well?

I noticed that when I go to Properties -> Transparency -> No Data Value and set "Additional No data value" to 0, the black rectangle disappears. But this has to be done per loaded raster. I can select more than one raster and right-click to properties, change the value, but it does not apply to all selected rasters. If you want to load many of these JPGs at once (like me), this can be cumbersome.

On the other hand, setting all surrounding raster elements to "0" just because the JPG is rendered rotated does not seem intuitive to me. In my opinion, "No Data" would be the obvious expectation, even more as 0 could be a valid raster value. Should not be "No Data" the default behaviour for the raster elements that do not originate from the JPG file?

#5 Updated by Giovanni Manghi 7 months ago

Roland Spielhofer wrote:

When I click into the raster I see lower values for all channels the darker the pixels are.

yes, for example see: https://www.rapidtables.com/web/color/RGB_Color.html

Would define the values of "0" to NODATA not also make all "perfect black" pixels in the JPG transparent as well?

the areas you would like to see transparent (by default) are 0,0,0 so perfect black. Making them NODATA you'll get the effect you want.

Please note that when warping a raster (changing its CRS) is normal to get a rotated image like yours. Is also up to the user to choose to make those "corners" NODATA or not. Please see the gdal warp tool manual (we have also it in the QGIS processing toolbox), in particular the "no data value for output bands".

#6 Updated by Giovanni Manghi 7 months ago

note: to me this ticket should be closed as invalid, there is no issue here, it is just a matter about the data. Also asking QGIS to make arbitrarily transparent by default valid raster pixels (that are not NODATA) makes no sense (as said it could be eventually an option for the default raster symbology).

#7 Updated by Peter Drexel 7 months ago

The jpg itself does not contain the black triangles, they are just drawn by QGIS if the Image is rotated using worldfile

This seems to be a shortage of showing worldfile-rotated images in QGIS. Also the Pixels themselves are not rotated, see also #15842 and #16537

Peter

#8 Updated by Giovanni Manghi 7 months ago

Peter Drexel wrote:

The jpg itself does not contain the black triangles, they are just drawn by QGIS if the Image is rotated using worldfile

This seems to be a shortage of showing worldfile-rotated images in QGIS. Also the Pixels themselves are not rotated, see also #15842 and #16537

ok then... I think that it all goes down to #15842 support for rotated rasters (regardless if they are geotiffs or other type with worldfile) is not there, so this is basically a duplicate of #15842.

#9 Updated by Giovanni Manghi 7 months ago

  • Operating System deleted (Windows)

Also available in: Atom PDF