Example #1
0
 public PhotoProcessor(PhotoPathHelper pathHelper, 
                       IPhotoOptimizer photoOptimizer, 
                       IRawConverter rawConverter, 
                       IExifReader exifReader,
                       IQualitySearcher qualitySearcher,
                       ProcessingTarget sourceTarget,
                       ProcessingTarget printTarget,  
                       ProcessingTarget xsTarget, 
                       ProcessingTarget smTarget, 
                       ProcessingTarget mdTarget, 
                       ProcessingTarget lgTarget, 
                       bool quiet)
 {
     _quiet = quiet;
     _pathHelper = pathHelper;
     _optimizer = photoOptimizer;
     _rawConverter = rawConverter;
     _exifReader = exifReader;
     _qualitySearcher = qualitySearcher;
     
     SourceTarget = sourceTarget;
     PrintTarget = printTarget;
     XsTarget = xsTarget;
     SmTarget = smTarget;
     MdTarget = mdTarget;
     LgTarget = lgTarget;
 }
Example #2
0
 ProcessedPhoto ProcessTarget(MagickWand wand, 
                              MagickWand optimizedWand, 
                              short adjustedQuality, 
                              ProcessingTarget target, 
                              string jpgName)
 {
     var srcWand = target.Optimize ? optimizedWand : wand;
     
     using(var tmpWand = srcWand.Clone())
     {
         var path = _pathHelper.GetScaledLocalPath(target.ScaledPathSegment, jpgName);
         uint width, height;
         
         if(target.MaxWidth > 0)
         {
             tmpWand.GetLargestDimensionsKeepingAspectRatio(target.MaxWidth, target.MaxHeight, out width, out height);
             
             tmpWand.ScaleImage(width, height);
         }
         else
         {
             width = wand.ImageWidth;
             height = wand.ImageHeight;
         }
         
         // sharpen after potentially resizing
         // http://www.imagemagick.org/Usage/resize/#resize_unsharp
         tmpWand.UnsharpMaskImage(0, 0.7, 0.7, 0.008);
         
         if(target.AdjustQuality)
         {
             tmpWand.ImageCompressionQuality = Convert.ToUInt32(adjustedQuality);
         }
         
         tmpWand.WriteImage(path, true);
         
         return new ProcessedPhoto
         {
             Target = target,
             LocalFilePath = jpgName, 
             WebFilePath = _pathHelper.GetScaledWebFilePath(target.ScaledPathSegment, jpgName),
             Width = width,
             Height = height
         };
     }
 }