提取小部分图像而不加载所有图像 [英] Extract small portion of image without loading all of it

查看:154
本文介绍了提取小部分图像而不加载所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大型JPG图像(比如20000x10000像素),想要从这些图像中提取子图像而不加载整个图像。

I have large JPG images ( say 20000x10000 pixels) and want to extract sub-images from these images without loading whole image.

我发现它可以通过使用这个ImageMagick命令:

I found it's possible by using this ImageMagick command:

convert -extract 226x248+4216+3377 a.jpg o.jpg

但我需要在我的C#WPF应用程序中使用它。

But I need to have it in my C# WPF app.

Magick.NET 没有实现提取方法。

这是否有任何.NET库?或者至少可以复制一个简单的exe,无需在客户机上安装像ImageMagick这样的大型库。

Is there any .NET library for this? Or at least a simple exe that can be copied without installing big libs like ImageMagick on client machines.

推荐答案

Magick.NET支持提取子图像。你应该使用裁剪方法:

Magick.NET does support extraction of a subimage. You should use the Crop method:

using(MagickImage image = new MagickImage("a.jpg"))
{
  image.Crop(new MagickGeometry(226,248,4216,3377));
  image.Write("o,jpg");
}

ImageMagick的-extract选项将在裁剪部分之前读取整个jpg你需要。所以这可能不是你问题的解决方案。仅适用于一小部分格式,图像将无法完全读取。

The -extract option of ImageMagick will read the whole jpg before cropping out the part you need. So maybe this is not a solution for your problem. Only for a small set of formats the image will not be read completely.

这篇关于提取小部分图像而不加载所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆