我正在使用以下代码调整GeoTIFF
文件的大小。我还想将标题从旧文件复制到新文件。
找到了this question。好像OP正在逐一读取和设置标签(此外,它似乎不适用于GeoTIFF
标签)。
是否可以将所有标头信息直接直接复制到新文件中?
using (var myEncoderParameters = new EncoderParameters(1))
{
var myEncoderParameter = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionNone);
myEncoderParameters.Param[0] = myEncoderParameter;
using (var srcImage = Image.FromFile(this.FilePath))
{
using (var newImage = new Bitmap(width, height))
{
using (var graphics = Graphics.FromImage(newImage))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.InterpolationMode = InterpolationMode.Bicubic;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.DrawImage(srcImage, new Rectangle(0, 0, width, height));
newImage.Save(destination, GetEncoderInfo("image/tiff"), myEncoderParameters);
}
}
}
}