Skip to content

Instantly share code, notes, and snippets.

@pratik-choudhari
Last active November 15, 2021 14:55
Show Gist options
  • Select an option

  • Save pratik-choudhari/2895a3707075ac9b71a9066369981dff to your computer and use it in GitHub Desktop.

Select an option

Save pratik-choudhari/2895a3707075ac9b71a9066369981dff to your computer and use it in GitHub Desktop.
pythonji code to convert images in jpg
import os as πŸ–₯️
import sys as πŸ› οΈ
from PIL import Image as πŸ–ΌοΈ
for πŸ“₯ in πŸ› οΈ.argv[2:]:
f, e = πŸ–₯️.path.splitext(πŸ“₯)
πŸ“€ = f + ".jpg"
if πŸ“₯ != πŸ“€:
try:
with πŸ–ΌοΈ.open(πŸ“₯) as πŸ“¦:
πŸ“¦.save(πŸ“€)
except OSError as ❌:
print("cannot convert", πŸ“₯, "error => ", str(❌))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment