Last active
August 29, 2015 14:15
-
-
Save agehrke/c9fbef951bd520db7ec6 to your computer and use it in GitHub Desktop.
Resize media image stream in Sitecore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mediaItem = GetMediaItemFromSomewhere(); | |
var mediaOptions = new global::Sitecore.Resources.Media.MediaOptions() { MaxWidth = 300 }; | |
var pipelineArgs = new global::Sitecore.Resources.Media.GetMediaStreamPipelineArgs(new global::Sitecore.Resources.Media.MediaData(mediaItem), mediaOptions); | |
// Run resizing pipeline | |
var resizeProcessor = new global::Sitecore.Resources.Media.ResizeProcessor(); | |
resizeProcessor.Process(pipelineArgs); | |
// Copy resized OutputStream to MemoryStream, or use OutputStream.Stream directly | |
var memoryStream = new System.IO.MemoryStream(); | |
pipelineArgs.OutputStream.CopyTo(memoryStream); | |
pipelineArgs.OutputStream.Dispose(); | |
memoryStream.Seek(0, System.IO.SeekOrigin.Begin); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment