Gallerist-AzureStorage
Gallerist classes for Azure Storage: implements reading image files from Azure Blob Service, and writing of resized pictures to the same.
$ pip install gallerist-azurestorage
This library is used in Torino, a file
explorer for Azure Storage Account, and in
Gallerist-AzureFunctions,
an Azure Functions front-end that uses
Gallerist library, to resize
pictures in Azure Storage Blob Service.
Example: synchronous code resizing pictures on Azure Storage
from gallerist import Gallerist, ImageSize
from galleristazurestorage import AzureBlobFileStore
store = AzureBlobFileStore.from_connection_string(
"<YOUR_CONNECTION_STRING>",
"CONTAINER_NAME",
)
gallerist = Gallerist(store)
# configuring sizes by mime (use '*' to match any other mime):
gallerist = Gallerist(
store,
sizes={
"image/jpeg": [ImageSize("a", 1200), ImageSize("b", 600), ImageSize("c", 300)],
"image/png": [ImageSize("a", 350), ImageSize("b", 250), ImageSize("c", 150)],
},
)
# the following function call causes the creation of several versions of the
# image in different sizes; note that this operation is CPU bound
metadata = gallerist.process_image("ORIGINAL_FILE_NAME_ALREADY_ON_STORAGE.png")
print(metadata)
Asynchronous example using executors (recommended for async scenarios)
import asyncio
import concurrent.futures
from gallerist import Gallerist, ImageSize
from galleristazurestorage import AzureBlobFileStore
store = AzureBlobFileStore.from_connection_string(
"<YOUR_CONNECTION_STRING>",
"CONTAINER_NAME",
)
gallerist = Gallerist(store)
# configuring sizes by mime (use '*' to match any other mime):
gallerist = Gallerist(
store,
sizes={
"image/jpeg": [ImageSize("a", 1200), ImageSize("b", 600), ImageSize("c", 300)],
"image/png": [ImageSize("a", 350), ImageSize("b", 250), ImageSize("c", 150)],
},
)
async def main():
loop = asyncio.get_event_loop()
with concurrent.futures.ProcessPoolExecutor() as pool:
metadata = await loop.run_in_executor(
pool, gallerist.process_image, "EXISTING_FILE_ON_STORAGE.jpg"
)
print(metadata)
asyncio.run(main())
Alternatively to using an executor explicitly, it is possible to use
loop.call_soon_threadsafe:
from gallerist import Gallerist, ImageSize
from galleristazurestorage import AzureBlobFileStore
store = AzureBlobFileStore.from_connection_string(
"<YOUR_CONNECTION_STRING>",
"CONTAINER_NAME",
)
gallerist = Gallerist(store)
# configuring sizes by mime (use '*' to match any other mime):
gallerist = Gallerist(
store,
sizes={
"image/jpeg": [ImageSize("a", 1200), ImageSize("b", 600), ImageSize("c", 300)],
"image/png": [ImageSize("a", 350), ImageSize("b", 250), ImageSize("c", 150)],
},
)
def process_image(image_path: str):
# configuring sizes by mime (use '*' to match any other mime):
gallerist = Gallerist(
store,
sizes={
"image/jpeg": [
ImageSize("a", 1200),
ImageSize("b", 600),
ImageSize("c", 300),
],
"image/png": [
ImageSize("a", 350),
ImageSize("b", 250),
ImageSize("c", 150),
],
},
)
metadata = gallerist.process_image(image_path)
print(metadata)
async def main():
loop = asyncio.get_event_loop()
loop.call_soon_threadsafe(process_image, "EXISTING_FILE_ON_STORAGE.jpg")
asyncio.run(main())
Asynchronous example using asynchronous methods from azure-storage-blob.aio
Note: azure-storage-blob requires aiohttp, and is not compatible with
concurrent.futures.ProcessPoolExecutor.
import asyncio
from gallerist import Gallerist, ImageSize
from galleristazurestorage.aio import AzureBlobAsyncFileStore
store = AzureBlobFileStore.from_connection_string(
"<YOUR_CONNECTION_STRING>",
"CONTAINER_NAME",
)
gallerist = Gallerist(store)
# configuring sizes by mime (use '*' to match any other mime):
gallerist = Gallerist(
store,
sizes={
"image/jpeg": [ImageSize("a", 1200), ImageSize("b", 600), ImageSize("c", 300)],
"image/png": [ImageSize("a", 350), ImageSize("b", 250), ImageSize("c", 150)],
},
)
async def main():
metadata = await gallerist.process_image_async(
"EXISTING_FILE_ON_STORAGE.jpg"
)
print(metadata)
asyncio.run(main())
Metadata
Release files for gallerist-azurestorage 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gallerist-azurestorage-0.0.5.tar.gz | 4.0 kB | Without provenance | Details for gallerist-azurestorage-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gallerist_azurestorage-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for gallerist_azurestorage-0.0.5-py3-none-any.whl |
Total release size: 8.7 kB
Release files / gallerist-azurestorage-0.0.5.tar.gz
| Download URL | gallerist-azurestorage-0.0.5.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
759a6f2c6c7459dc713fc902c3d1ac10c7f7f94fb975ccd017426ddde4d60990
|
|
BLAKE2b-256 checksum How to use checksums |
b8c277c9528aa14b13d8aac8912db9c971f4c6dd13126e9abcb50af09ea49eaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / gallerist_azurestorage-0.0.5-py3-none-any.whl
| Download URL | gallerist_azurestorage-0.0.5-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c92f25fdfe99c024b7774421408d79a74afe7e12e4692499273fefcbdb3d4598
|
|
BLAKE2b-256 checksum How to use checksums |
bc372c936ea7b792ea252600afffff16c68f45feb07e0dc4150de06c8bfaa94a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for gallerist-azurestorage 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.