gdal - Using gdal_translate to compress multiple TIFF files - Stack Overflow

admin2025-04-30  0

Gdal_translate throws "too many command options."

I used a gdal_translate code in a batch file to convert multiple JP2 files to TIFF format, and it worked well.

I then modified that same code to use to compress these TIFF files as they were too large (250 Mb+ each). The code I tried is below:

for %%f in (*.tif) do (

   echo %%~nf

   gdal_translate -of -b 1 -b 2 -b 3 -co COMPRESS=JPEG -co TILED=YES -co PHOTOMETRIC=YCBCR %%f %%~nf.tif

)

This batch file is located in the same directory as the existing TIFF files, and I run it via the Windows command prompt. Launching it, it just scrolls through each of the files, and returns an error (for each) that there are "too many command options." There are over 700 files to be converted, and it's too labor intensive to try to do then individually. Note that it is not necessary to rename the original TIFF file after the compression routine runs, as long as it works (if I do so individually, the TIFF file size goes from roughly 250 Mb to 37 Mb).

Hopefully the problem is something simple in my code, so any suggestions/corrections would be greatly appreciated!

转载请注明原文地址:http://anycun.com/QandA/1746021207a91454.html