scottel
scottel

Reputation: 3

How do I get a thumbnail of a certain size from an image file using Box Java SDK?

I can currently retrieve a thumbnail of an image file just fine with the following code:

BoxImageRequestObject obj = null;
thumbnail = client.getFilesManager().getThumbnail( entryId, fileExtention, obj );

However, the thumbnail obtained is too small. So, I need to be able to request a certain size. I have tried using pagePreviewRequestObject method that allows for setting the dimensions. But it doesn't work.

BoxImageRequestObject obj = BoxImageRequestObject.pagePreviewRequestObject(page, minWidth, maxWidth, minHeight, maxHeight);
thumbnail = client.getFilesManager().getThumbnail( entryId, fileExtention, obj );

Please tell me how to request a thumbnail by size using the Box Java SDK.

Thanks!

Upvotes: 0

Views: 489

Answers (2)

RikyTres
RikyTres

Reputation: 676

Another solution may be the follow:

// assert size = 32 || 128 || 256
BoxImageRequestObject obj = BoxImageRequestObject.pagePreviewRequestObject(page, size, size, size, size);
BoxThumbnail = client.getFilesManager().getThumbnail( entryId, fileExtention, obj );

Upvotes: 0

Jian Lin
Jian Lin

Reputation: 331

The BoxImageRequestObject is for the purpose tweaking requests. In this scenario you'll want to do a : BoxImageRequestObject.previewRequestObject().setMinHeight(size).setMaxHeight(size).setMinWidth(size).setMaxWidth(size);

This way you are specifically requesting a thumbnail of a certain size. However please be aware that although server always try to render the thumbnail with the size requested, the size requested may not exist in server. In this case server will get an thumbnail with different size back.

Upvotes: 1

Related Questions