Opened 8 years ago

Closed 8 years ago

#6387 closed defect (worksforme)

gdal_translate When using a path like /tmp/tXYZLKS/output.png the file is generated black.

Reported by: rserrano Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

Good afternoon. I'm reporting an strange bug. I'm using gdal_translate for an automated task, my command is like this:

gdal_translate -of PNG -scale /path/to/file/input.tif /tmp/tXYZKS/output.png

When I do it, it generates a black file. At first I thought it was a problem with the source file, but then tested after changing the directory to the target folder and it worked. I have tested it not only in my system but in a server. I have tested it with several different files, including NASA satellite files, geomapapp files, etc. A workaround to the problem is changing to the target directory and not using the full path. The transformation, dimensions, etc of the file appear correct, however it's only black.

Best regards, Ricardo.

Attachments (1)

satelite.tif (560.4 KB ) - added by rserrano 8 years ago.
GeoTiff Satelite

Download all attachments as: .zip

Change History (6)

comment:1 by Even Rouault, 8 years ago

I've just tried "gdal_translate -scale byte.tif /tmp/tXYZKS/output.png -of png" with https://svn.osgeo.org/gdal/trunk/autotest/gcore/data/byte.tif and it works

by rserrano, 8 years ago

Attachment: satelite.tif added

GeoTiff Satelite

comment:2 by rserrano, 8 years ago

Hi, I have attached a file you can use to reproduce the problem. Putting -of PNG at the beginning or the end seems to affect the end result too. The command I'm using is:

gdal_translate -of PNG -scale /home/ricardo/project/tests/files/satelite.tif /tmp/tmpSKJXKJD/output.png

with a tmp dir generated with python tempfile.mkdtemp

Last edited 8 years ago by rserrano (previous) (diff)

comment:3 by Even Rouault, 8 years ago

I tried the above command (slightly modified to work with my home directory) and it works fine. Perhaps it comes from your own code ? I'm wondering if you might not have an issue with the way you would invoke gdal_translate from Python. Are you sure the forked process has finished before you try accessing the data ? Some Python API are asynchronous, so you might read a partially written file. That would explain what you see.

comment:4 by rserrano, 8 years ago

It's the weirdest bug I have seen. I have tested it from the command line after getting the black files in my python code.

gdal version: GDAL 1.11.2, released 2015/02/10, Ubuntu 14.04.4 LTS

Popen with cwd solves the problem.

comment:5 by Even Rouault, 8 years ago

Resolution: worksforme
Status: newclosed

I'm quite skeptical this is a problem in GDAL itself. Closing under that assumption. Reopen if you can provide a self contained Python script demonstrating the problem.

Note: See TracTickets for help on using tickets.