I have an issue where our custom pipeline which crops images is not running correctly for some images. It was working fine and still seems to work correctly for the existing images but for new images it no longer works correctly.
These are the parameters we are sending to fire our pipeline:
/-/media/test-image.jpg?mw=660&mh=530&as=1¢ercrop=1
It is not cropping new images anymore and if I look at the error in the logs this seems to be falling back to the out of the box image pipeline:
14028 16:47:19 ERROR Could not run the 'getMediaStream' pipeline for '/sitecore/media library/test-image'. Original media data will be used. Exception: System.ArgumentException Message: Parameter is not valid. Source: System.Drawing at System.Drawing.Bitmap..ctor(Stream stream) at Sitecore.Resources.Media.SaveColorProfileProcessor.Process(GetMediaStreamPipelineArgs args) at (Object , Object[] ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Resources.Media.Media.GetStreamFromPipeline(MediaOptions options, Boolean& canBeCached)
I've looked into it and thought it might be this bug, but it's for an older version of Sitecore:
https://kb.sitecore.net/articles/856744
More info here:
https://sitecorebasics.wordpress.com/2015/11/21/could-not-run-the-getmediastream-pipeline/
I've also checked the permissions on the images and they seem fine and this issue seems to affect all image types, jpeg, gif, pn etc so I'm a bit stumped what might be causing it.
Other details: We are Running Sitecore 8.1 - update 2.
--Update--
I've taken a copy of the SaveColorProfileProcessor Pipeline and it is indeed throwing an error when trying to read the properties of the image. I've wrapped it in a try{}catch{} and this is skips over the error and proceeds as expected with other Pipelines and resizes the images correctly. I have opened a ticket with Sitecore Support regarding this and why GetMediaStream() is returning this error:
'mediaStream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
I'll update here further once I know more.
try
{
PropertyItem propertyItem =
((IEnumerable<PropertyItem>) new Bitmap(mediaStream).PropertyItems)
.SingleOrDefault<PropertyItem>((Func<PropertyItem, bool>) (x => x.Id == 34675));
if (propertyItem == null)
return;
args.CustomData.Add("ColorProfile", (object) propertyItem);
}
catch (Exception ex)
{
Log.Error("Error saving colour profile: " + ex.Message, ex);
return;
}
as=1¢ercrop=1
- have you tried without those?