I have 1000s of images sitting in a container on my blob storage. I want to process these images one by one in Python and spit out the new images out into a new container (the process is basically detecting and redacting objects). Downloading the images locally is not an option because they take up way too much space.
So far, I have been able to connect to the blob and have created a new container to store the processed images in, but I have no idea how to run the code to process the pictures and save them to the new container. Can anyone help with this?
Code so far is:
from azure.storage.file import FileService
from azure.storage.blob import BlockBlobService
# call blob service for the storage acct
block_blob_service = BlockBlobService(account_name = 'mycontainer', account_key = 'HJMEchn')
# create new container to store processed images
container_name = 'new_images'
block_blob_service.create_container(container_name)
Do I need to use get_blob_to_stream or get_blob_to_path from here: https://azure-storage.readthedocs.io/ref/azure.storage.blob.baseblobservice.html so I don't have to download the images?
Any help would be much appreciated!
As mentioned in the comment, you may need to download or stream your blobs and then upload the results after processing them to your new container.
You could refer to the samples to download and upload blobs as below.
Download the blobs:
Upload blobs to the container:
Update:
Try to use the code by stream as below, for more details you could see the two links: link1 and link2 (they are related issue, you could see them together).