Gwenview cannot open png by matplotlib

(21:05:01) [firestar@ThinkPad homework_2]$ gwenview deblended\ segmentation\ map.png 
kf.i18n.kuit: "Unknown subcue ':whatsthis,' in UI marker in context {@info:whatsthis, %1 the action's text}."
org.kde.kdegraphics.gwenview.lib: Unresolved mime type  "image/x-mng"
org.kde.kdegraphics.gwenview.lib: Unresolved raw mime type  "image/x-samsung-srw"
Segmentation fault (core dumped)

I generated a png image by matplotlib using jupyter, that is, pyplot.savefig(), which generates a png file by default.

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html

but when I open it in gwenview it crashed and said that above.

By the way, I use gwenview 22.04.3-1 on KDE 5.24.6

A first test should tell if the issue comes from matplotlib or gwenview:

  • if you can open other PNG files, it may come from matplotlib not correctly producing PNG files
  • if the PNG file can be opened by another image reader, it may come from gwenview not correctly reading PNG files
  1. other PNG files can be opened by Gwenview
  2. PNG from matplotlib cannot be opened by Gwenview on ext4, but I can open them after I copy them to my NTFS partition (and copy back).
  3. PNG can be opened on Windows, using its default viewer.

By the way, I use gwenview 22.04.3-1 on KDE 5.24.6

Are the checksums SHA1 of these PNG files changed after copying to NFTS partition (and copy back)?

A copy operation, regardless of traversing filesystems, should not alter the data whatsoever.

Unless you mean “copy” as in you exported or re-saved the PNG from an image viewer/editor.


UPDATE: Or the copy operation (to and from an NTFS filesystem) reset ownership/permissions of the files in question. (Assuming the reason Gwenview could not open these PNGs was due to ownership/permission issues.)

1 Like

I will try again.

not all figures have this bug. the figure is generated like this:

plt.figure(figsize=(15, 15))

ax1 = plt.subplot(121)
ax1.imshow(segm, cmap=segm.cmap, origin="lower", interpolation="nearest")
plt.title("segmentation map")

ax2 = plt.subplot(122)
segm_deblend = deblend_sources(
    convolved_data, segm, npixels=10, nlevels=64, contrast=0.01
)  #!!!
plt.imshow(
    segm_deblend, cmap=segm_deblend.cmap, origin="lower", interpolation="nearest"
)
plt.title("deblended segmentation map")
plt.savefig("deblended segmentation map")

SHA has not changed:

$ sha1sum deblended\ segmentation\ map.png 
90e2c0706e4120992c6f8c3fd650f108dff33940  deblended segmentation map.png
$ cd ~/D
$ sha1sum deblended\ segmentation\ map.png 
90e2c0706e4120992c6f8c3fd650f108dff33940  deblended segmentation map.png

I have no issue with that in VM. The PNG file can be opened.

:point_down:

For Gwenview to crash/fail/abort when attempting to open a PNG file, but then later it works for the same PNG file (with the same SHA value) simply because you copied it back and forth from an NTFS filesystem, strongly hints to permissions/ownership. (Or something related to such.)