Find all .png files, convert them to .jpg, rename to .png

Obsidian-paste-png-to-jpeg (GitHub - musug/obsidian-paste-png-to-jpeg: When pasting screenshots into obsidian notes, convert the images to jpeg and compress them) not working with canvases and I want something more universal and one click simple.

1 Like

I made this small Python script that converts all .png into .jpg.
Also, it goes inside each of the .md files and replaces them with the new filename.
The script will delete the original .png file.

Take a look at: Find all .png files, convert them to .jpg, rename to .png · GitHub

1 Like

I’m sorry, but how to use it as one click solution? To improve the quality of the conversion I need to change “quality=60”?

As a recommendation, do a full backup of your vault before running the script. Because the changes are destructive. I mean, there is no undo. This scripts deletes the original .png and modifies the .md.

If you know how to run a Python script, you need to just:

python.exe image_compress.py "C:\My Documents\Vault" -q 80

The first argument is the path, is to say where the vault is.
The second, if you want to limit the replacement of the new path inside the .md. I recommend to repite the first argument.
The third, is as you mentioned, the .jpg quality. The higher the number, the better the quality, lower the compression, higher the file size.

Notice I had updated the code to run with shell arguments.
The script still located at Find all .png files, convert them to .jpg, rename to .png · GitHub

1 Like