ITADN

optimize plugin chokes on sligthly broken images

#8574ClosedPlasmaHH 创建于 2026-03-12
change request
P
PlasmaHHcommented
### Context _No response_ ### Bug description Hi, great that we can all now use the optimize plugin, however in existing projetcs we have it seems that some images are slightly broken so that PIL cannot properly handle them ( we are using 9.7.5 of material) I think the best way to provoke this in an existing installation is to rename a png file with transparency to a jpeg, that will cause it to try to save an RGBA image as a jpeg which will throw an exception (OSError in my case, might be different in others) My suggestion ist that somewhere in _optimize_image or _optimize_image_jpeg (or png too?) these are caught, logged and the file is copied as-is since material won't be able to do anything about it anyways. ### Related links - [Reporting a bug](https://squidfunk.github.io/mkdocs-material/contributing/reporting-a-bug/) - ### Reproduction in an existing installation is to rename a png file with transparency to a jpeg ### Steps to reproduce in an existing installation is to rename a png file with transparency to a jpeg ### Browser _No response_ ### Before submitting - [x] I have read and followed the [bug reporting guidelines](https://squidfunk.github.io/mkdocs-material/contributing/reporting-a-bug/). - [x] I have attached links to [the documentation](https://squidfunk.github.io/mkdocs-material/), and possibly related [issues](https://github.com/squidfunk/mkdocs-material/issues) and [discussions](https://github.com/squidfunk/mkdocs-material/discussions). - [x] I assure that I have [removed all customizations](https://squidfunk.github.io/mkdocs-material/contributing/reporting-a-bug/#remove-customizations) before submitting this bug report. - [x] I have attached a __.zip file__ with a [minimal reproduction](https://squidfunk.github.io/mkdocs-material/guides/creating-a-reproduction/) using the [built-in info plugin](https://squidfunk.github.io/mkdocs-material/plugins/info/).
关闭于 2026-03-12 2 条评论