I'm struggling to find a way to reduce an image file's size before uploading it to Google Cloud. I have tried encoding it with Base64, but without success.
The idea is to save storage space. The file is 3 MB and should be smaller. This is the code I currently have (without compressing):
def upload_to_bucket(blob_name, file_path, bucket_name):
try:
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob(blob_name)
blob.upload_from_filename(file_path)
print("successfully uploaded {} to {}".format(file_path, bucket_name))
return True
except Exception as e:
print(e)
return False
upload_to_bucket("QR2", 'QRcode_Scanner\whitecards\WC_QR_Scan.jpg', 'test_storage_whitecards')
If you need any additional information, please ask :)