Search code examples
imagemagickpngtiff

How to convert 32-bit tiff to 16-bit png? Grayscale displacement texture


I need to convert 32bit tif to 16bit, but preserve all range of details. I've tried convert -normalize, convert -depth 16, convert -depth 16 -normalize and it just gets rid of all the details and part of the texture is just black.

The image I got is here, displacement texture of the moon

Image:
  Filename: ldem_64.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 23040x11520+0+0
  Resolution: 100x100
  Print size: 230.4x115.2
  Units: PixelsPerInch
  Colorspace: Gray
  Type: Grayscale
  Endianness: LSB
  Depth: 32/16-bit
  Channel depth:
    Gray: 16-bit
  Channel statistics:
    Pixels: 265420800
    Gray:
      min: -597319  (-9.1145)
      max: 704960 (10.757)
      mean: -34039.6 (-0.519411)
      median: -52133.1 (-0.7955)
      standard deviation: 144682 (2.2077)
      kurtosis: 0.855997
      skewness: 0.540128
      entropy: 0.244393
  Rendering intent: Undefined
  Gamma: 0.454545
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 23040x11520+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: TopLeft
  Properties:
    comment: IDL TIFF file
    date:create: 2019-06-05T20:21:05+00:00
    date:modify: 2019-06-05T20:21:05+00:00
    date:timestamp: 2022-11-24T22:57:25+00:00
    quantum:format: floating-point
    signature: cb63f78e418cec4a32935a7eeb388c3dc541bf2ed95d46de2d35e70c2e3ad805
    tiff:alpha: unspecified
    tiff:document: ldem_64.tif
    tiff:endian: lsb
    tiff:photometric: min-is-black
    tiff:rows-per-strip: 1
    tiff:software: IDL 8.7.2, Harris Geospatial Solutions, Inc.
    tiff:timestamp: 2019:05:20 12:47:07
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 1012.59MiB
  Number pixels: 265.421M
  Pixel cache type: Memory
  Pixels per second: 59.0163MP
  User time: 3.672u
  Elapsed time: 0:05.497
  Version: ImageMagick 7.1.0-52 Q16-HDRI x64 04ee6ce:20221106 https://imagemagick.org

aodhasdoashdoasd cannot post the question cuz alot of "code"


Solution

  • I am not sure what you want, but perhaps just -auto-level in Imagemagick.

    Input:

    I downloaded a smaller version, ldem_4.tif (1440x720) and using IM 7 (which you need for the HDRI compile since your image is outside the normal range of 16-bit integers).

    magick ldem_4.tif -auto-level x.png
    

    enter image description here