MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.26k stars 21.43k forks source link

Need documentation for thumbnail generation using SDK #57283

Closed GeekTrainer closed 4 years ago

GeekTrainer commented 4 years ago

While an example exists for generating a thumbnail with REST, one doesn't exist for the SDK. Because the reference documentation for the SDK is auto-generated it contains no samples, so determining how to access the image from the return value for generate_thumbnail is challenging at best.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

SnehaAgrawal-MSFT commented 4 years ago

@GeekTrainer Thanks for the feedback! We are currently investigating and will update you shortly.

RohitMungi-MSFT commented 4 years ago

@GeekTrainer A sample is available for this call on the SDK page of github here.

from PIL import Image
import io

width = 50
height = 50
url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg"

thumbnail = client.generate_thumbnail(width, height, url)

for x in thumbnail:
    image = Image.open(io.BytesIO(x))

image.save('thumbnail.jpg')

@PatrickFarley can we include this sample in the documentation for future updates of this page?

GeekTrainer commented 4 years ago

Unfortunately the samples site isn't easily discoverable. I spent a good two hours searching through the docs, Bing and Google, before finally finding a Stack Overflow page which gave me a hint as to how to work with it.

# Avoiding using PIL
thumbnail = client.generate_thumbnail(x, y, url)
thumbnail_bytes = bytearray()
for chunk in thumbnail:
    thumbnail_bytes.extend(chunk)
RohitMungi-MSFT commented 4 years ago

@GeekTrainer Thanks for the feedback. The link to the source code of azure SDK code for cognitive services is usually at the top of the page.

image

Along with some examples from the Azure-Samples repo at the bottom of page for all services.

image

These links usually contain examples that we cannot cover in the documentation and I usually use these pages to lookup for additional examples. I hope these are helpful as you explore more about our services.

RohitMungi-MSFT commented 4 years ago

@GeekTrainer We will now proceed to close this thread. If there are further questions regarding this matter, please tag @RohitMungi-MSFT in your reply.

GeekTrainer commented 4 years ago

@RohitMungi-MSFT