/// <summary>
    /// Adjusts brightness modifying lightness channel of Lab color space
    /// </summary>
    private static void AdjustLightnessLab()
    {
        using (var lChannel = new Bitmap())
            using (var aChannel = new Bitmap())
                using (var bChannel = new Bitmap())
                {
                    using (var reader = ImageReader.Create("../../../../_Input/Chicago.jpg"))
                        using (var labConverter = new ColorConverter(PixelFormat.Format24bppLab))
                            using (var splitter = new LabChannelSplitter())
                            {
                                splitter.L = lChannel;
                                splitter.A = aChannel;
                                splitter.B = bChannel;

                                Pipeline.Run(reader + labConverter + splitter);
                            }

                    lChannel.ColorAdjustment.Brightness(brightnessAmount);

                    using (var combiner = new LabChannelCombiner())
                        using (var rgbConverter = new ColorConverter(PixelFormat.Format24bppRgb))
                            using (var writer = ImageWriter.Create("../../../../_Output/AdjustLightnessLab.jpg"))
                            {
                                combiner.L = lChannel;
                                combiner.A = aChannel;
                                combiner.B = bChannel;

                                rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

                                Pipeline.Run(combiner + rgbConverter + writer);
                            }
                }
    }
Exemplo n.º 2
0
        private Pipeline CreateTilePipeline(Rectangle boundsOnResizedImage)
        {
            var tilePipeline = new Pipeline();

            var fileCache = FileCache.GetInstance();

            var fileName = _filePrefix + "_" + _tiles.Count + _fileExtension;

            fileCache.RegisterPublicTempFileName(fileName, false);

            tilePipeline.Add(new Crop(boundsOnResizedImage));

            if ((_bitmapViewer.SourceImageParams.ColorProfile != null && _bitmapViewer.SourceImageParams.ColorProfile.ColorSpace == ColorSpace.Cmyk) ||
                _bitmapViewer.SourceImageParams.PixelFormat.HasAlpha)
            {
                var cc = new Transforms.ColorConverter(PixelFormat.Format24bppRgb)
                {
                    ColorManagementEngine =
                        ColorManagementEngine.LittleCms,
                    DestinationProfile = ColorProfile.FromSrgb()
                };

                tilePipeline.Add(cc);
            }

            tilePipeline.Add(ImageWriter.Create(fileCache.GetAbsolutePublicCachePath(fileName), _encoderOptions));

            return(tilePipeline);
        }
    /// <summary>
    /// Sets embedded profile
    /// </summary>
    private static void SetEmbeddedProfile()
    {
        using (var bitmap = new Bitmap("../../../../_Input/Chicago.jpg"))
        {
            bitmap.ColorProfile = ColorProfile.FromSrgb();

            bitmap.Save("../../../../_Output/SetEmbeddedProfile.jpg");
        }
    }
Exemplo n.º 4
0
 /// <summary>
 /// Converts colors using LittleCMS
 /// </summary>
 private static void ConvertColorsLittleCms()
 {
     using (var bitmap = new Bitmap("../../../../_Input/Copenhagen_CMYK.jpg"))
     {
         // LittleCMS is a default color management engine, so no need to specify it
         // bitmap.ColorManagement.ColorManagementEngine = ColorManagementEngine.LittleCms;
         bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();
         bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
         bitmap.Save("../../../../_Output/ConvertColorsLittleCms.jpg");
     }
 }
    private static void CmykToRgbWithColorManagement()
    {
        CmykColor cmykColor = new CmykColor(20, 42, 211, 40)
        {
            Profile = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc")
        };

        RgbColor rgbColor = cmykColor.To <RgbColor>(ColorProfile.FromSrgb());

        Console.WriteLine("With color management: {0} to {1}", cmykColor, rgbColor);
    }
    /// <summary>
    /// Converts color space from CMYK to RGB with color management using memory-friendly Pipeline API
    /// </summary>
    private static void CmykToRgbWithColorManagementMemoryFriendly()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_CMYK.jpg"))
            using (var converter = new ColorConverter(PixelFormat.Format24bppRgb))
                using (var writer = ImageWriter.Create("../../../../_Output/CmykToRgbWithColorManagementMemoryFriendly.jpg"))
                {
                    converter.DestinationProfile = ColorProfile.FromSrgb();

                    Pipeline.Run(reader + converter + writer);
                }
    }
    private static void RgbToLabWithColorManagement()
    {
        RgbColor rgbColor = new RgbColor(223, 210, 30)
        {
            Profile = ColorProfile.FromSrgb()
        };

        LabColor labColor = rgbColor.To <LabColor>();

        Console.WriteLine("With color management: {0} to {1}", rgbColor, labColor);
    }
    /// <summary>
    /// Converts color space from CMYK to RGB with color management
    /// </summary>
    private static void CmykToRgbWithColorManagement()
    {
        using (var bitmap = new Bitmap("../../../../_Input/Copenhagen_CMYK.jpg"))
        {
            bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();

            bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);

            bitmap.Save("../../../../_Output/CmykToRgbWithColorManagement.jpg");
        }
    }
Exemplo n.º 9
0
    private static LabColor RgbToLabColor(RgbColor color)
    {
        using (var bitmap = new Aurigma.GraphicsMill.Bitmap(1, 1, PixelFormat.Format24bppRgb, color))
        {
            bitmap.ColorProfile = ColorProfile.FromSrgb();

            bitmap.ColorManagement.Convert(PixelFormat.Format24bppLab);

            return((LabColor)bitmap.GetPixel(0, 0));
        }
    }
    private static void RgbToCmykWithColorManagement()
    {
        RgbColor rgbColor = new RgbColor(253, 202, 12)
        {
            Profile = ColorProfile.FromSrgb()
        };

        CmykColor cmykColor = rgbColor.To <CmykColor>("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc", transformationIntent: ColorTransformationIntent.Perceptual);

        Console.WriteLine("With color management: {0} to {1}", rgbColor, cmykColor);
    }
    /// <summary>
    /// Converts pixel format to Format24bppRgb (RGB, 8-bit per channel, no alpha channel)
    /// </summary>
    private static void ConvertTo24bppRgb(string inputPath, string outputPath)
    {
        using (var bitmap = new Bitmap(inputPath))
        {
            if (bitmap.PixelFormat.IsRgb && bitmap.PixelFormat != PixelFormat.Format24bppRgb)
            {
                bitmap.ColorManagement.BackgroundColor = RgbColor.White;

                // Assign some default color profile
                if (bitmap.ColorProfile == null)
                {
                    bitmap.ColorProfile = ColorProfile.FromSrgb();
                }

                bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();

                bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
            }

            if (bitmap.PixelFormat.IsGrayscale)
            {
                bitmap.ColorManagement.BackgroundColor = new GrayscaleColor(255);

                // Assign some default color profile
                if (bitmap.ColorProfile == null)
                {
                    bitmap.ColorProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOnewspaper26v4_gr.icc");
                }

                bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();

                bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
            }

            if (bitmap.PixelFormat.IsCmyk)
            {
                bitmap.ColorManagement.BackgroundColor = new CmykColor(0, 0, 0, 0, 255);

                // Assign some default color profile
                if (bitmap.ColorProfile == null)
                {
                    bitmap.ColorProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
                }

                bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();

                bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
            }


            bitmap.Save(outputPath);
        }
    }
    /// <summary>
    /// Converts color space from CMYK to RGB with color management
    /// </summary>
    private static void ConvertCmykToRgbMemoryFriendly()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_CMYK.jpg"))
            using (var converter = new ColorConverter(PixelFormat.Format24bppRgb))
                using (var writer = ImageWriter.Create("../../../../_Output/PF_ConvertCmykToRgbMemoryFriendly.jpg"))
                {
                    converter.DefaultSourceProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
                    converter.DestinationProfile   = ColorProfile.FromSrgb();

                    Pipeline.Run(reader + converter + writer);
                }
    }
Exemplo n.º 13
0
    /// <summary>
    /// Converts colors using LittleCMS and memory-friendly Pipeline API
    /// </summary>
    private static void ConvertColorsLittleCmsMemoryFriendly()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_CMYK.jpg"))
            using (var converter = new ColorConverter())
                using (var writer = ImageWriter.Create("../../../../_Output/ConvertColorsLittleCmsMemoryFriendly.jpg"))
                {
                    // LittleCMS is a default color management engine, so no need to specify it
                    // converter.ColorManagementEngine = ColorManagementEngine.LittleCms;
                    converter.DestinationProfile = ColorProfile.FromSrgb();

                    Pipeline.Run(reader + converter + writer);
                }
    }
    /// <summary>
    /// Converts color space from RGB to CMYK with color management using memory-friendly Pipeline API
    /// </summary>
    private static void RgbToCmykMemoryFriendly()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_RGB.jpg"))
            using (var converter = new ColorConverter())
                using (var writer = ImageWriter.Create("../../../../_Output/RgbToCmykWithColorManagementMemoryFriendly.jpg"))
                {
                    converter.DestinationPixelFormat = PixelFormat.Format32bppCmyk;
                    converter.DefaultSourceProfile   = ColorProfile.FromSrgb();
                    converter.DestinationProfile     = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
                    converter.TransformationIntent   = ColorTransformationIntent.Perceptual;

                    Pipeline.Run(reader + converter + writer);
                }
    }
    private static void Main(string[] args)
    {
        ShowColorProfileInfo(ColorProfile.FromSrgb());
        ShowColorProfileInfo(new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc"));
        ShowColorProfileInfo(new ColorProfile("../../../../_Input/ColorProfiles/ISOnewspaper26v4_gr.icc"));

        GetEmbeddedProfile();
        GetEmbeddedProfileMemoryFriendly();

        SetEmbeddedProfile();

        RetainEmbeddedProfile();
        RetainEmbeddedProfileMemoryFriendly();
    }
    /// <summary>
    /// Color proofing - CMYK to RGB using destination (screen) and target device profile
    /// </summary>
    private static void ColorProofing()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_CMYK.jpg"))
            using (var converter = new ColorConverter())
                using (var writer = ImageWriter.Create("../../../../_Output/ColorProofing.jpg"))
                {
                    // LittleCMS is a default color management engine, so no need to specify it
                    // converter.ColorManagementEngine = ColorManagementEngine.LittleCms;
                    converter.DestinationProfile  = ColorProfile.FromSrgb();
                    converter.TargetDeviceProfile = new ColorProfile(@"../../../../_Input/ColorProfiles/ISOnewspaper26v4_gr.icc");

                    Pipeline.Run(reader + converter + writer);
                }
    }
    /// <summary>
    /// Converts pixel format to Format24bppRgb (RGB, 8-bit per channel, no alpha channel) using memory-friendly Pipeline API
    /// </summary>
    private static void ConvertTo24bppRgbMemoryFriendly(string inputPath, string outputPath)
    {
        using (var reader = ImageReader.Create(inputPath))
            using (var converter = new ColorConverter(PixelFormat.Format24bppRgb))
                using (var writer = ImageWriter.Create(outputPath))
                {
                    if (reader.PixelFormat.IsRgb && reader.PixelFormat != PixelFormat.Format24bppRgb)
                    {
                        converter.BackgroundColor = RgbColor.White;

                        //Assign some default color profile
                        converter.DefaultSourceProfile = ColorProfile.FromSrgb();
                        converter.DestinationProfile   = ColorProfile.FromSrgb();

                        Pipeline.Run(reader + converter + writer);

                        return;
                    }

                    if (reader.PixelFormat.IsGrayscale)
                    {
                        converter.BackgroundColor = new GrayscaleColor(255);

                        //Assign some default color profile
                        converter.DefaultSourceProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOnewspaper26v4_gr.icc");
                        converter.DestinationProfile   = ColorProfile.FromSrgb();

                        Pipeline.Run(reader + converter + writer);

                        return;
                    }

                    if (reader.PixelFormat.IsCmyk)
                    {
                        converter.BackgroundColor = new CmykColor(0, 0, 0, 0, 255);

                        //Assign some default color profile
                        converter.DefaultSourceProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
                        converter.DestinationProfile   = ColorProfile.FromSrgb();

                        Pipeline.Run(reader + converter + writer);

                        return;
                    }

                    //Or just copy file from inputPath to outputPath
                    Pipeline.Run(reader + writer);
                }
    }
    /// <summary>
    /// Generates an RGB preview of CMYK color conversion using memory-friendly Pipeline API
    /// </summary>
    private static void PreviewRgbToCmykOnScreenMemoryFriendly()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_RGB.jpg"))
            using (var converter = new ColorConverter())
                using (var writer = ImageWriter.Create("../../../../_Output/PreviewRgbToCmykOnScreenMemoryFriendly.jpg"))
                {
                    converter.DestinationPixelFormat = PixelFormat.Format24bppRgb;
                    converter.DefaultSourceProfile   = ColorProfile.FromSrgb();
                    converter.TargetDeviceProfile    = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
                    converter.DestinationProfile     = ColorProfile.FromScreen();
                    converter.TransformationIntent   = ColorTransformationIntent.Perceptual;

                    Pipeline.Run(reader + converter + writer);
                }
    }
Exemplo n.º 19
0
        public static ColorProfile GetSrgbProfile()
        {
            if (_srgbColorProfile == null)
            {
                lock (_srgbSync)
                {
                    if (_srgbColorProfile == null)
                    {
                        _srgbColorProfile = ColorProfile.FromSrgb();
                    }
                }
            }

            return(_srgbColorProfile);
        }
    /// <summary>
    /// Converts color space from RGB to CMYK with color management
    /// </summary>
    private static void RgbToCmyk()
    {
        using (var bitmap = new Bitmap("../../../../_Input/Copenhagen_RGB.jpg"))
        {
            if (bitmap.ColorProfile == null)
            {
                bitmap.ColorProfile = ColorProfile.FromSrgb();
            }

            bitmap.ColorManagement.DestinationProfile   = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
            bitmap.ColorManagement.TransformationIntent = ColorTransformationIntent.Perceptual;

            bitmap.ColorManagement.Convert(PixelFormat.Format32bppCmyk);

            bitmap.Save("../../../../_Output/RgbToCmykWithColorManagement.jpg");
        }
    }
    /// <summary>
    /// Converts color space from CMYK (no assigned color profile) to RGB with color management
    /// </summary>
    private static void CmykNoProfileToRgbWithColorManagement()
    {
        using (var bitmap = new Bitmap("../../../../_Input/Copenhagen_CMYK_NoColorProfile.jpg"))
        {
            // Assign some default color profile
            if (bitmap.ColorProfile == null)
            {
                bitmap.ColorProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
            }

            bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();

            bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);

            bitmap.Save("../../../../_Output/CmykNoProfileToRgbWithColorManagement.jpg");
        }
    }
    /// <summary>
    /// Generates an RGB preview of CMYK color conversion
    /// </summary>
    private static void PreviewRgbToCmykOnScreen()
    {
        using (var bitmap = new Bitmap("../../../../_Input/Copenhagen_RGB.jpg"))
        {
            if (bitmap.ColorProfile == null)
            {
                bitmap.ColorProfile = ColorProfile.FromSrgb();
            }

            bitmap.ColorManagement.TargetDeviceProfile = new ColorProfile("../../../../_Input/ColorProfiles/ISOcoated_v2_eci.icc");
            bitmap.ColorManagement.DestinationProfile  = ColorProfile.FromScreen();

            bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);

            bitmap.Save("../../../../_Output/PreviewRgbToCmykOnScreen.jpg");
        }
    }
Exemplo n.º 23
0
    /// <summary>
    /// Converts colors using Adobe Color Management Module (CMM) and memory-friendly Pipeline API
    /// </summary>
    private static void ConvertColorsAdobeCmmMemoryFriendly()
    {
        using (var reader = ImageReader.Create("../../../../_Input/Copenhagen_CMYK.jpg"))
            using (var converter = new ColorConverter())
                using (var writer = ImageWriter.Create("../../../../_Output/ConvertColorsAdobeCmmMemoryFriendly.jpg"))
                {
                    converter.ColorManagementEngine = ColorManagementEngine.AdobeCmm;
                    converter.DestinationProfile    = ColorProfile.FromSrgb();

                    try
                    {
                        Pipeline.Run(reader + converter + writer);
                    }
                    catch (CMAdobeModuleLoadException e)
                    {
                        Console.WriteLine("Can't load Adobe Color Management Module (CMM).\n" + e.Message);
                        Console.WriteLine("http://www.adobe.com/support/downloads/detail.jsp?ftpID=3618");
                    }
                }
    }
Exemplo n.º 24
0
    /// <summary>
    /// Converts colors using Adobe Color Management Module (CMM)
    /// </summary>
    private static void ConvertColorsAdobeCmm()
    {
        using (var bitmap = new Bitmap("../../../../_Input/Copenhagen_CMYK.jpg"))
        {
            bitmap.ColorManagement.ColorManagementEngine = ColorManagementEngine.AdobeCmm;
            bitmap.ColorManagement.DestinationProfile    = ColorProfile.FromSrgb();

            try
            {
                bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
            }
            catch (CMAdobeModuleLoadException e)
            {
                Console.WriteLine("Can't load Adobe Color Management Module (CMM).\n" + e.Message);
                Console.WriteLine("http://www.adobe.com/support/downloads/detail.jsp?ftpID=3618");
                return;
            }

            bitmap.Save("../../../../_Output/ConvertColorsAdobeCmm.jpg");
        }
    }
Exemplo n.º 25
0
    /// <summary>
    /// Tints using Lab color space
    /// </summary>
    private static void TintUsingLab(RgbColor color)
    {
        // You can hardcode a = 20, b = 60 for sepia effect
        var labColor = RgbToLabColor(color);
        var a        = labColor.A;
        var b        = labColor.B;

        using (var lChannel = new Bitmap())
        {
            // Convert to Lab color space and get lightness channel
            using (var reader = ImageReader.Create("../../../../_Input/Chicago.jpg"))
                using (var labConverter = new ColorConverter(PixelFormat.Format24bppLab))
                    using (var splitter = new LabChannelSplitter())
                    {
                        splitter.L = lChannel;

                        Pipeline.Run(reader + labConverter + splitter);
                    }

            // Create a and b channels, combine with lightness channel and convert to RGB color space
            using (var combiner = new LabChannelCombiner())
                using (var aChannel = new Bitmap(lChannel.Width, lChannel.Height, PixelFormat.Format8bppGrayscale,
                                                 new GrayscaleColor((byte)(a + 127))))
                    using (var bChannel = new Bitmap(lChannel.Width, lChannel.Height, PixelFormat.Format8bppGrayscale,
                                                     new GrayscaleColor((byte)(b + 127))))
                        using (var rgbConverter = new ColorConverter(PixelFormat.Format24bppRgb))
                            using (var writer = ImageWriter.Create("../../../../_Output/TintUsingLab_" + color.ToString() + ".jpg"))
                            {
                                combiner.L = lChannel;
                                combiner.A = aChannel;
                                combiner.B = bChannel;

                                rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

                                Pipeline.Run(combiner + rgbConverter + writer);
                            }
        }
    }
Exemplo n.º 26
0
    /// <summary>
    /// Adjusts hue modifying [a] component of Lab color space
    /// </summary>
    private static void AdjustColorsUsingLab()
    {
        // L - lightness
        // a - green/red
        // b - blue/yellow

        using (var lChannel = new Bitmap())
            using (var aChannel = new Bitmap())
                using (var bChannel = new Bitmap())
                {
                    using (var reader = ImageReader.Create("../../../../_Input/Chicago.jpg"))
                        using (var labConverter = new ColorConverter(PixelFormat.Format24bppLab))
                            using (var splitter = new LabChannelSplitter())
                            {
                                splitter.L = lChannel;
                                splitter.A = aChannel;
                                splitter.B = bChannel;

                                Pipeline.Run(reader + labConverter + splitter);
                            }

                    // Increase yellow
                    bChannel.ColorAdjustment.ChannelBalance(new float[] { 0.1f }, new float[] { 1f });

                    using (var combiner = new LabChannelCombiner())
                        using (var rgbConverter = new ColorConverter(PixelFormat.Format24bppRgb))
                            using (var writer = ImageWriter.Create("../../../../_Output/AdjustColorsUsingLab.jpg"))
                            {
                                combiner.L = lChannel;
                                combiner.A = aChannel;
                                combiner.B = bChannel;

                                rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

                                Pipeline.Run(combiner + rgbConverter + writer);
                            }
                }
    }
    /// <summary>
    /// Corrects tone modifying lightness component of Lab color space
    /// </summary>
    private static void AdjustLevelsUsingLab()
    {
        // L - lightness
        // a - green/red
        // b - blue/yellow

        using (var lChannel = new Bitmap())
            using (var aChannel = new Bitmap())
                using (var bChannel = new Bitmap())
                {
                    using (var reader = ImageReader.Create("../../../../_Input/Chicago.jpg"))
                        using (var labConverter = new ColorConverter(PixelFormat.Format24bppLab))
                            using (var splitter = new LabChannelSplitter())
                            {
                                splitter.L = lChannel;
                                splitter.A = aChannel;
                                splitter.B = bChannel;

                                Pipeline.Run(reader + labConverter + splitter);
                            }

                    lChannel.ColorAdjustment.Levels(0.03F, 0.9F, 0.05F, 1.5F, 0.7F, HistogramMode.Sum);

                    using (var combiner = new LabChannelCombiner())
                        using (var rgbConverter = new ColorConverter(PixelFormat.Format24bppRgb))
                            using (var writer = ImageWriter.Create("../../../../_Output/AdjustLevelsUsingLab.jpg"))
                            {
                                combiner.L = lChannel;
                                combiner.A = aChannel;
                                combiner.B = bChannel;

                                rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

                                Pipeline.Run(combiner + rgbConverter + writer);
                            }
                }
    }
Exemplo n.º 28
0
        private string SavePreviewImage()
        {
            if (!_previewImageEnabled)
            {
                return("");
            }

            var fileName = _fileCache.GetPublicTempFileName(".jpg");

            var width  = (int)(Math.Max(SourceImageParams.Width * ActualSizeHorizontalScale / _previewImageResizeRatio, 1));
            var height = (int)(Math.Max(SourceImageParams.Height * ActualSizeVerticalScale / _previewImageResizeRatio, 1));

            var pipeline = new Pipeline
            {
                ImageReader.Create(_fileCache.GetAbsolutePrivateCachePath(SourceCacheFilename)),
                new Resize(width, height, ResizeInterpolationMode.Anisotropic9)
            };

            if ((SourceImageParams.ColorProfile != null && SourceImageParams.PixelFormat.ColorSpace != ColorSpace.Rgb) ||
                SourceImageParams.PixelFormat.HasAlpha)
            {
                var cc = new Transforms.ColorConverter(PixelFormat.Format24bppRgb)
                {
                    ColorManagementEngine = ColorManagementEngine.LittleCms,
                    DestinationProfile    = ColorProfile.FromSrgb()
                };

                pipeline.Add(cc);
            }

            pipeline.Add(new JpegWriter(_fileCache.GetAbsolutePublicCachePath(fileName), 60));
            pipeline.Run();
            pipeline.DisposeAllElements();

            return(_fileCache.GetRelativePublicCachePath(fileName));
        }