How can we generate thumbnails programmatically?

Vote:
 

Hi,

We have added a new thumbnail size for our variation images like so:

[ContentType(
DisplayName = "Blah Image",
GUID = "404b9288-41a7-43e2-8498-bdd504a78f96")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png")]
public class InRiverImage : CommerceImage
{

[ImageDescriptor(Width = 96, Height = 96)]
public virtual Blob MediumThumbnail {
get; set;
}
}

This code works and hitting the image URL seems to generate, and then display the image.

But, when accessing the image via code before the thumbnail has been generated by manually visiting the URL does NOT work. I.e. we are creating a PDF with product images inside it using C# and the images are retrieved like this:

contentRepository.Get(variationImageContentReference).MediumThumbnail.OpenRead();

where MediumThumbnail returns null. Is there any way we can trigger the generation of medium thumbnails for all our products via code?

Thanks,

Jordan

#182520
Sep 22, 2017 7:18
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.