0

I have an input image with a size of ~18MB, which is mostly black and only 25-30% contains data. After I run gdal translate command like this:

gdal_translate -ot Byte -scale_1 0 200 -scale_2 0 184 -scale_3 0 174 "input_image.tif" "output_image.tif"

the result image size is ~910MB. Using -co compress=LZW option makes the resulting image weigh ~230MB.

What is my mistake in using gdal translate command, which makes the resulting image that large? And how to solve it?

Here is a link to the input image file: https://mega.nz/file/79x3QRaR#RGqYkXUkgYlpkYh_JKxFPhX-eVFMDg_Wl1rdVd78Y1w

1
  • Gdalinfo reveals that the source file is using: COMPRESSION=YCbCr JPEG JPEG_QUALITY=75 SOURCE_COLOR_SPACE=YCbCr. So, compressed with a lossy but more effective method than LZW. Use the same compression and photometric options and you should be close to the original file size.
    – user30184
    Oct 27, 2022 at 19:06

1 Answer 1

1

Not having access to the files makes answering this hard. However, you may want to set the no data value to 0, and pass more options to the compression:

gdal_translate -ot Byte -a_nodata 0 \
               -scale_1 0 200 -scale_2 0 184 -scale_3 0 174 \
               "input_image.tif" "output_image.tif" \
               -co "COMPRESS=LZW" -co "TILED=YES" -co "PREDICTOR=2"

There's a lot more information on compression options here, including lossy methods.

3
  • Thanks, compression options reduced the image size to ~130Mb. I've also added a link to the input file. Oct 27, 2022 at 19:05
  • The file would appear to be compressed with a lossy compressor (JPEG). So you won't get similar compression ratios unless you use something like that.
    – Jose
    Oct 27, 2022 at 19:32
  • Updated answer to cover all the options available in GDAL
    – Jose
    Oct 28, 2022 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.