import os
import sys
import subprocess
def compress_jpg(file_path, quality):
"""
Compress jpg files
"""
if not os.path.exists(file_path):
print("File not found")
return
if not os.path.isfile(file_path):
print("Not a file")
return
if not file_path.endswith(".jpg"):
print("Not a jpg file")
return
if quality < 0 or quality > 100:
print("Quality should be between 0 and 100")
return
subprocess.call(["convert", file_path, "-quality", str(quality), file_path])
def main():
"""
Main function
"""
compress_jpg(sys.argv[1], int(sys.argv[2]))
if __name__ == "__main__":
main()
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)