-
Notifications
You must be signed in to change notification settings - Fork 515
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
Ability to load PNG images with "resolution" data embedded depends on OS "formats" setting #1515
Comments
wxpython 4.0.6 + python 3.7 seem not to have this issue (i failed to build wx 4.0.6 for python 3.8) |
This type of trace has popped up before with other users. No one really knows fully, but optimizing the image sometimes works. Try that first. Also if you need to wrap your path with abspath, do so. If that don't work jump on the bandwagon and search the other issues for your maybe solution... |
I decided just to downgrade to 4.0.6 for now (to fix this issue and #1008). If 1008 gets fixed, i might consider batch-converting the images. |
I really haven't any idea because the locales thing doesn't effect me, just the If I where you, I'd investigate more specifically the operating system stuff. Downgrading isn't a fix, just a temporary workaround, unless your downgrading to Win7 which just retired along with py27. Maybe if the users that are having these issues provided more specifics about other things and or talked with one another, might come up with a common thing amongs't them. |
I was able to replicate the issue myself. It's definitely the "Format" setting affecting it. Don't get me wrong, downgrading is a sub-par solution to me in general. If it was only this issue i'd look into repackaging the images. However, inconsistent behavior bothers me (with "English (US)" wx takes "wrong" image just fine, with "English (European)" it does not), and 4.0.7post2 has another regression which repackaged images do not fix. On top of that. 4.0.7post2 doesn't contain any changes which would be interesting for my app, so reverting to 4.0.6 is a no-brainer. |
What if you create a locale just after you create the App?
I've had to put this workaround in all my wx applications (with wx 2.9 or later) otherwise they'll throw that same exception. Never had this issue with wx 2.8 |
@cbeytas do I need to set to app/wx somehow? Just initializing it does not help. |
I just realized that when I added
Just wanted to comment on that - this is defintely not the case, first images I reexported with gimp is still broken. |
I removed resolution from all offending images in my app, but still have issues. Below is example of another manifestation, apparently wx built-in bitmaps also suffer from this issue:
I tested 5 built-in images, 4 of them are "broken":
One of them loaded just fine:
So, i guess, rolling back is a way to go. |
@DarkFenX I optimized your repo images, to see if that might help you. Had to run the optimizer overnight since you have so many images in the repo. Saved about 10% in bytes at max, so wait until I send a pull reqz before testing again. Might take a few hours... |
Note that image manipulation applications do not optimize images, but usually attach a profile by default. I see that gimp has that option to not attach a profile. Photoshop used to do the same thing. IIRC krita has an option for not attaching a profile also. This should be default behavior if you are saving images for embedding or wx with whatever version of libPNG causes the issues. |
FYI this is still an issue for my app. My current solution was rolling back to python 3.7 + wxpython 4.0.6, but a few days ago I've got a report that app fails to launch on some "Format" settings too: pyfa-org/Pyfa#2174 Correct solution would be to upgrade to 3.8 + 4.0.7post2 + reset locale, but then I run into this issue which leads to crash in some parts of my app, no matter the system settings. So, for the love of god please remove resolution metadata from wx built-in images (or optimize them, whatever it does) and make another bugfix wx release with fixed images. Or maybe suggest some way to work around it, which is not very obvious to me. |
@DarkFenX Do you mean the pyEmbeddedImages? Do you know which ones are causing the problems? Specifics would help. I've optimized some of them in the past. I don't recall Ive done them all. The famfamfam flags iirc didnt get finished... |
I know wx image codes which screw it up for me, but not actual image files, sorry. More on that in the comment: #1515 (comment) |
ummmm. those are probably at the wxWidgets level or operating system snagged images.... I haven't even looked into those. |
I folks want to work on creating a PyArtProvider that would probably work, but having source images would be needed and figure out what to make as an image for each code. Andrea had some crystal images for he used for one of his dialog modules. Something along those lines... from wx.lib.PyArtProvider import ArtProvider as PyArtProvider
img = PyArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_BUTTON) I think something like this would work if other images are os images that cant be optimized(Ex: they might come from a DLL or something...) |
If you are getting the `iCCP: known incorrect sRGB profile' warning class MyApp(wx.App):
""""""
def OnInit(self):
""""""
# wx.Log.EnableLogging(enable=False) wxPy 4.0 and before
wx.Image.SetDefaultLoadFlags(0) # wxPy 4. This works with wxpy4.1 class MyPanel(wx.Panel):
""""""
def __init__(self, parent, id=wx.ID_ANY,
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.BORDER_SUNKEN, name='panel'):
""""""
wx.Panel.__init__(self, parent, id, pos, size, style, name)
image = wx.Image()
image.SetLoadFlags(0)
image.LoadFile('iCCP_known_incorrect_sRGB_profile.png')
wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
Python 3.8.2, wxpython 4.0.7post2, with the example I linked above (with
After I modified the code to following:
It breaks on setting flags:
Just realized that 4.1 is released, going to give it a try. |
python 3.8.2, wxpython 4.1.0, i get the same result with basic example I provided (the edit: just to clarify: it happens not just when I reset locale in my code, it also happens if I set system format to singaporean english as well (as mentioned in original report). |
@DarkFenX @RobinD42 Ok I finally managed to get the error playing around for a bit. import wx
class MyApp(wx.App):
""""""
def OnInit(self):
""""""
# un/comment out line as necessary
# wx.Image.SetDefaultLoadFlags(0) # wxPy 4.1
return True
if __name__ == '__main__':
print(wx.version())
app = MyApp(False)
app.ResetLocale()
img = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_BUTTON)
print(img) ...Using singapore english did not matter. Using
|
@Metallicow how would you advise to work around it? By avoiding python 3.8? |
idunno. Ask/Wait for Robin to reply and in the meantime find a Python that doesn't produce the error. |
There will be a new version of |
Operating system: Windows 8.1, windows 10
wxPython version & source: 4.0.7post2 from pip
Python version & source: python 3.8.1
Description of the problem:
Image itself: https://github.com/pyfa-org/Pyfa/blob/b15f9766c121b331bae1be0b07b3b231b85a624d/imgs/gui/fighter_small.png
Repro steps:
Result:
If i set format to English (US), it loads
Expected: image is loaded.
The text was updated successfully, but these errors were encountered: