Necesito ayuda para poder convertir de formato .png a .json y viceversa .json a .png

Hola buenas tardes, me encuentro realizando un proyecto el cual pueda convierta imágenes .png a .json y luego pueda hacer lo contrario, convertirlas de .json a .png, el problema es que aun que el código lo hace, abro la imagen y me dice: parece que el formato de este archivo no es compatible, y no encuentro como resolver eso.

Agradecería mucho que me pudieran ayudar a resolver esto.

Can it round-trip? In other words, if you convert a .png file to a .json file and then back again, is what you get the same as the original?

Seria lo ideal si, es lo que estoy buscando, que mantenga la misma imagen

PNG is a lossless format, so I don’t see why it couldn’t round-trip, although I suppose it depends on what you’re storing as JSON.

Te puedo compartir el codigo para que lo revises ?, por que no entiendo por que no funciona, puesto que tengo en cuenta lo mismo que dijiste, y justo por eso use formato .png

OK, but I can’t promise anything!

Okey de igual forma te agradezco, por tomarte el tiempo de ayudarme, yo descargue la librería de stepic, con eso solamente debería de funcionar adecuadamente.

(Attachment Codigo.py is missing)

Me compartes por favor un correo en el que te pueda enviar el archivo del codigo ?

Instead of trying to attach the code or send it privately, please prepare a short example of the part that actually does the work relevant to the problem. Then, format it properly in a post here, following the advice in the pinned thread.