[gdal-dev] JPEG/PNG 12 bits GDAL python

jesus.moran at solute.es jesus.moran at solute.es
Fri Jan 22 05:18:03 PST 2021


Hi,

It work for me too like this!! The -ot uint16 was the key! Thank you a lot Jukka. Im still trying to find the way to do this in python though.



Jesús Maria Morán Rosado
Project Engineer
 
Av. Cerro del Águila, 3, 28703 S.S. de los Reyes, Madrid
CONFIDENTIALITY: This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium.

-----Original Message-----
From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> On Behalf Of jratike80
Sent: viernes, 22 de enero de 2021 12:15
To: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] JPEG/PNG 12 bits GDAL python

Hi,

With my GDAL 3.1.4 from OSGeo4W converting a single band Float32 DEM file into JPEG compressed TIFF and into plain JPEG succeeded with these commands:

gdal_translate L2431.tif -co COMPRESS=JPEG -ot uint16 -co NBITS=12 out.tif gdal_translate L2431.tif -of JPEG -ot uint16 -co NBITS=12 out.jpg

I have never played with 12 bit JPEGs before. The documentation was not very clear to me and I am not sure if it is essential to first define the data type into uint16 and then limit the number of NBITS into 12.
But without using -ot uint16 I got messages like

Warning 6: Only NBITS=16 is supported for data type Float32 Warning 1: NBITS=32 is invalid for data type UInt16. Using NBITS=16 ERROR 1: JPEGSetupEncode:BitsPerSample 16 not allowed for JPEG

Warning 6: driver JPEG does not support creation option NBITS 0Warning 6: JPEG driver doesn't support data type Float32. Only eight and twelve bit bands supported (Mk1 libjpeg).

I wonder if there is any way for the user to find out if their GDAL is compiled with 12 bit JPEG support.

-Jukka Rahkonen-



GDAL - Dev mailing list wrote
> Hello and thank you in advance,
> 
>  
> 
> Im trying to generate png and jpeg 12 bits images from a GTiff single 
> band file with no success. I know is there a way to generate 12 bits 
> images in the GDAL command line as I have seen in some examples 
> (“gdal_translate mandril_rgb.tif -co COMPRESS=JPEG -co 
> PHOTOMETRIC=YCBCR -co NBITS=12
> out.tif”) but trying it with my singlebands tif files it only 
> generates a black image (with PHOTOMETRIC set to MINISBLACK). Is it 
> only a method for rgb files?
> 
> Searching in the python API I only can find gdalconst for 16, 32 and 
> 64 bits formats. Is there a way to do the same with 12 bits files?
> 
>  
> 
> Kind regards
> 
>  
> 
> 
>  <http://www.solute.es/>
> 
> 
> Jesús Maria Morán Rosado
> Project Engineer
> 
> Av. Cerro del Águila, 3, 28703 S.S. de los Reyes, Madrid
> 
> CONFIDENTIALITY: This e-mail and any attachments are confidential and 
> may be privileged. If you are not a named recipient, please notify the 
> sender immediately and do not disclose the contents to another person, 
> use it for any purpose or store or copy the information in any medium.
> 
>  
> 
> 
> _______________________________________________
> gdal-dev mailing list

> gdal-dev at .osgeo

> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 
> image001.gif (2K)
> <http://osgeo-org.1560.x6.nabble.com/attachment/5455390/0/image001.
> gif>





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list