JoshSmith#33361
Having some issues resizing the photo/image that I am replacing using the following code. It doesn't seem to matter what ResizeMode I choose the results are the same, the image seems to be stretched without regards to the aspect ratio. My understanding is that ResizeMode.ImageFill is supposed to proportionally resize and crop the image, not stretch to fill. It's possible I'm implementing it incorrectly, which is why I am hoping for some feedback. Thanks in advance.
private static MemoryStream ReplacePhoto(MemoryStream preparedStream, PsdProcessor psdProcessor)
{
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type != FrameType.Raster)
return processor.ProcessFrame(frame);
if (frame.Name == "Photo")
{
// Now the memory stream can be used with ImageReader.Create
using (var background = ImageReader.Create(preparedStream))
{
background.CloseOnDispose = false;
return frame.ToGraphicsContainer(background, ResizeMode.ImageFill);
}
}
return processor.ProcessFrame(frame);
};
return preparedStream;
}
private static MemoryStream ReplacePhoto(MemoryStream preparedStream, PsdProcessor psdProcessor)
{
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type != FrameType.Raster)
return processor.ProcessFrame(frame);
if (frame.Name == "Photo")
{
// Now the memory stream can be used with ImageReader.Create
using (var background = ImageReader.Create(preparedStream))
{
background.CloseOnDispose = false;
return frame.ToGraphicsContainer(background, ResizeMode.ImageFill);
}
}
return processor.ProcessFrame(frame);
};
return preparedStream;
}