Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsLayoutExporter export png file failed. #51947

Open
2 tasks
hjcook opened this issue Feb 21, 2023 · 7 comments
Open
2 tasks

QgsLayoutExporter export png file failed. #51947

hjcook opened this issue Feb 21, 2023 · 7 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers

Comments

@hjcook
Copy link

hjcook commented Feb 21, 2023

What is the bug or the crash?

env: Ubuntu 20 64bit,qgis 3.26

When I export layout to png file with qgis python ,it's can export png file successful,but png file did not draw layer from postgis,it's only draw the layer from shp file,and reported a error :

"ERROR 6: The PNG driver does not support update access to existing datasets."

export code:
exporter = QgsLayoutExporter(layout)
imageSettings=QgsLayoutExporter.ImageExportSettings()
exporter.exportToImage(os.path.join(PROJECT_PATH,outFile), imageSettings)

Steps to reproduce the issue

e7148f622731090d9dd7ece67ce07ba

Versions

QGIS 3.26

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@hjcook hjcook added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Feb 21, 2023
@nicogodet
Copy link
Member

Could you please try on 3.28.3 ?
Share a sample project to reproduce ?

See also: https://gis.stackexchange.com/questions/360254/pyqgis-exporting-print-layout-error-6-the-png-driver-does-not-support-update

@nicogodet nicogodet added the Feedback Waiting on the submitter for answers label Feb 21, 2023
@github-actions
Copy link

github-actions bot commented Mar 8, 2023

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Mar 8, 2023
@github-actions
Copy link

github-actions bot commented Apr 6, 2023

While we hate to see this happen, this issue has been automatically closed because it has not had any activity in the last 42 days despite being marked as feedback. If this issue should be reconsidered, please follow the guidelines in the previous comment and reopen this issue.
Or, if you have any further questions, there are also further support channels that can help you.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2023
@tsmcgrath
Copy link

Re-opening. I am exporting 400 maps in an interactive Python console loop and I'm now getting this error.
ERROR 6: The PNG driver does not support update access to existing datasets.

On MacOS, Mac M1, Sequoia 15.11, QGIS 3.40
It's not failing and the exported PNG's look fine. I'll work on getting a repro in place.

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 2, 2025
@nicogodet nicogodet reopened this Jan 2, 2025
@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jan 3, 2025

@tsmcgrath, the "The PNG driver does not support update access to existing datasets." error message is thrown by the GDAL/OGR library because QgsLayoutExporter.exportToImage

gdal::dataset_unique_ptr outputDS( GDALOpen( file.toUtf8().constData(), GA_Update ) );
tries to "update" the already exported image file in order to add the georeferencing information inside it, while this is not possibile for the "PNG" GDAL driver.
Since the error doesn't actually affects the exporting functionality, you can avoid it to be displayed just following the advice at https://gis.stackexchange.com/questions/360254/pyqgis-exporting-print-layout-error-6-the-png-driver-does-not-support-update as already suggested in a previous comment.

Anyway, it looks like the error message doesn't show up using QGIS 3.40.2 with GDAL/OGR 3.9.3 on my Windows 10 system. Where exactly is the error message displayed on your system?

@tsmcgrath
Copy link

I am using the 3.40.1 build from the conda builder releases because it runs natively on a Mac ARM:
https://github.com/opengisch/qgis-conda-builder/releases

But, I have to launch QGIS from a command line and it is in that command terminal window that I see the errors scroll by when I'm running map image exports. I will see if it recurs with 3.40.2.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jan 7, 2025

Hi @rouault, do you think it would be useful and worth to wrap gdal::dataset_unique_ptr outputDS( GDALOpen( file.toUtf8().constData(), GA_Update ) );

gdal::dataset_unique_ptr outputDS( GDALOpen( file.toUtf8().constData(), GA_Update ) );
inside

  CPLPushErrorHandler( CPLQuietErrorHandler );
  CPLErrorReset();

  CPLPopErrorHandler();

since it tries to open indiscriminately any file format in "update mode", while it is not possible for many of them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers
Projects
None yet
Development

No branches or pull requests

4 participants