Opened 12 years ago

Closed 12 years ago

#2476 closed defect (worksforme)

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


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;

	return true;

Change History (3)

comment:1 Changed 12 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.

comment:2 Changed 12 years ago by warmerdam

Component: defaultGDAL_Raster
Keywords: jpeg added

comment:3 Changed 12 years ago by Even Rouault

Resolution: worksforme
Status: newclosed

Closing due to lack of feedback from reporter.

Note: See TracTickets for help on using tickets.