现在我正在使用Dianoga(https://github.com/kamsar/Dianoga)进行图像压缩。
此工具适用于png和jpg / jpeg文件,PNG文件工作正常。但是,如果我上传JPG文件,则上传工具框会像屏幕截图一样冻结。
这是执行行。
var jpegtran = Process.Start(ToolPath, " -optimize -copy none -progressive -outfile \"{0}\" \"{0}\"".FormatWith(tempFilePath));
如果我将代码更改为
var jpegtran = Process.Start(ToolPath, " -optimize -copy none -progressive -outfile \"{1}\" \"{0}\"".FormatWith(tempFilePath));
JPG文件已更新,但没有压缩过程。日志说,
“错误无法为'/ sitecore /媒体库/ Images / satellite-westtibet'运行'getMediaStream'管道。将使用原始媒体数据”
这是我在/ App_Config / Include /中的web.config文件。
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<processors>
<attachFile argsType="Sitecore.Pipelines.Attach.AttachArgs">
<processor mode="on" type="Validations.Attach.ImageAttachMaxSize, Custom.Validations" patch:before="processor [@type='Sitecore.Pipelines.Attach.CheckSize,Sitecore.Kernel']">
<restrictedExtensions hint="list">
<extension>.jpg</extension>
<extension>.jepg</extension>
<extension>.png</extension>
<extension>.bmp</extension>
</restrictedExtensions>
</processor>
</attachFile>
<uiUpload>
<processor mode="on" type="Validations.Upload.ImageUploadMaxSize, Custom.Validations" patch:before="processor [@type='Sitecore.Pipelines.Upload.CheckSize, Sitecore.Kernel']">
<restrictedExtensions hint="list">
<extension>.jpg</extension>
<extension>.jepg</extension>
<extension>.png</extension>
<extension>.bmp</extension>
</restrictedExtensions>
</processor>
</uiUpload>
</processors>
<pipelines>
<getMediaStream>
<processor type="Validations.Compression.ImageCompression, Custom.Validations" />
</getMediaStream>
</pipelines>
<settings>
<setting name="Media.MaxImageSizeInDatabase" value="600KB" />
<setting name="Media.Resizing.Quality" value="72" />
</settings>
</sitecore>
</configuration>
错误的Width和Height值为空
最佳答案
最后解决了这个问题。问题是我不得不“解除阻止” jpegtran.exe文件。而已。