C# 调整大小,将 .tif 重新保存为 .jpg 为新图像提供蓝色色调

发布于 2024-10-06 08:19:06 字数 855 浏览 9 评论 0原文

我正在构建一个批处理器来将 .tif 图像目录保存为 .jpg。处理工作正常。然而,渲染的 jpg 带有蓝色调。它们不是“蓝色”,尽管它们具有较冷的色调,蓝色色调。原版的颜色更明亮、更温暖。这就是我创建调整大小的 jpeg 的方式:

        Bitmap bitmap = new Bitmap(image.Image, size);

        Graphics graphics = Graphics.FromImage(bitmap);
        graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
        graphics.DrawImage(image.Image, 0, 0, size.Width, size.Height);

        // Get EncoderInfo("image/jpeg") gets the jpeg Codec by mime type
        bitmap.Save(path, GetEncoderInfo("image/jpeg"), EncoderParameters);

原始 tif 图像的大小为 7MB - 与渲染的 jpeg 相比很大。也许这与此有关。没有把握。

我在谷歌上一无所获。有谁有这方面的经验或对下一步尝试什么有任何建议吗?谢谢!

I'm building a batch processor to save a directory of .tif images as .jpgs. The processing is working fine. However, the rendered jpgs have a blue-ish tint to them. They aren't "blue", as much as they have a cooler hue, a blue hue. The originals are much brighter and warmer in color. This is how I am creating the resized jpeg:

        Bitmap bitmap = new Bitmap(image.Image, size);

        Graphics graphics = Graphics.FromImage(bitmap);
        graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
        graphics.DrawImage(image.Image, 0, 0, size.Width, size.Height);

        // Get EncoderInfo("image/jpeg") gets the jpeg Codec by mime type
        bitmap.Save(path, GetEncoderInfo("image/jpeg"), EncoderParameters);

The original tif images are 7MB is size - large in comparison to the rendered jpegs. Perhaps that has something to do with it. Not sure.

I've come up empty on the Googles. Does anyone have any experience with this or any advice on what to try next? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

失眠症患者 2024-10-13 08:19:06

原始文件可能具有颜色配置文件。在这种情况下,您还需要将该信息复制到新文件中。我不知道如何使用 .NET 的成像类来做到这一点。

It could be that the original files have a color profile. In that case, you need to copy that information into the new file as well. I don't know how to do that with .NET's imaging classes.

简单爱 2024-10-13 08:19:06

我首先建议一个测试:

  1. 创建一个单色的纯图像。
  2. 将其转换为 jpeg。
  3. 然后检查照片包中的色调是否确实发生了变化或者是否是您的看法。

I would first suggest a test:

  1. Create a plain image with a single colour.
  2. Convert it to jpeg.
  3. Then check in a photo package if the hue has actually changed or if it is your perception.
囍孤女 2024-10-13 08:19:06

从 MSDN 文档来看,您似乎可以更简单地执行此操作(假设 image.Image 是实际的 System.Drawing.Image 实例)


image.Image.Save(路径,System.Drawing.ImageFormat.Jpeg)

这可能会有所帮助 - 看起来您正在将 TIF 转换为位图,然后才转换为 JPG。

From the MSDN documentation, it looks like you can be doing this somewhat simpler (assuming image.Image is an actual System.Drawing.Image instance):


image.Image.Save(path, System.Drawing.ImageFormat.Jpeg)

That might help - it looks like you're taking your TIF, converting to a bitmap, and only then converting to a JPG.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文