Ticket #2476 (closed defect: worksforme)

Opened 5 years ago

Last modified 5 years ago

CreateCopy() on JPEG driver always fails

Reported by: kabiraman Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.5.1
Severity: normal Keywords: jpeg
Cc:

Description

I am trying to create a JPEG of a raster dataset, however CreateCopy?() fails (get back an empty pointer) on all raster datasets I've tried. Here's the code:

bool GDALFileConverterProcess::writeToFile(GDALDataset* pDS)
{
	const char* pFormat = "JPEG";
	GDALDriver* pDriver;
	char** ppMetadata;

	pDriver = GetGDALDriverManager()->GetDriverByName(pFormat);

	if(pDriver == NULL)
	{
		return false;
	}

	ppMetadata = pDriver->GetMetadata();

    if(!CSLFetchBoolean( ppMetadata, GDAL_DCAP_CREATECOPY, FALSE))
	{
		return false;
	}

	GDALDatasetH pConvertedDataset = 0;
		pConvertedDataset = 
			pDriver->CreateCopy(m_strSavePath.c_str(), pDS, FALSE, NULL, NULL, NULL);
	if (pConvertedDataset == 0)
	{
		return false;
	}
	GDALClose(pConvertedDataset);

	return true;
}

Change History

Changed 5 years ago by warmerdam

The presented code is not sufficent to diagnose the problem.

Is an error issued with CPLError() during the create copy operation? If stderr is lost in your setup, you can still call CPLGetLastErrorMsg() after the CreateCopy?() call.

Generally speaking an explanatory error should be issued if the createcopy fails. The JPEG format only supports a fairly limited number of configurations (8bit*1band and 8bit*3bands) so that might be the issue, but you provide no information on the input image configurations.

Changed 5 years ago by warmerdam

  • keywords jpeg added
  • component changed from default to GDAL_Raster

Changed 5 years ago by rouault

  • status changed from new to closed
  • resolution set to worksforme

Closing due to lack of feedback from reporter.

Note: See TracTickets for help on using tickets.