mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.0 KiB
96 lines
3.0 KiB
// --------------------------------------------------------------------------------------------------------------------
|
|
// <copyright file="TiffFormat.cs" company="James South">
|
|
// Copyright (c) James South.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
// <summary>
|
|
// Provides the necessary information to support tiff images.
|
|
// </summary>
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
namespace ImageProcessor.Imaging.Formats
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
|
|
/// <summary>
|
|
/// Provides the necessary information to support tiff images.
|
|
/// </summary>
|
|
public class TiffFormat : FormatBase
|
|
{
|
|
/// <summary>
|
|
/// Gets the file header.
|
|
/// </summary>
|
|
public override byte[] FileHeader
|
|
{
|
|
get
|
|
{
|
|
return new byte[] { 77, 77, 42 };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the list of file extensions.
|
|
/// </summary>
|
|
public override string[] FileExtensions
|
|
{
|
|
get
|
|
{
|
|
return new[] { "tif", "tiff" };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the standard identifier used on the Internet to indicate the type of data that a file contains.
|
|
/// </summary>
|
|
public override string MimeType
|
|
{
|
|
get
|
|
{
|
|
return "image/tiff";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the <see cref="ImageFormat" />.
|
|
/// </summary>
|
|
public override ImageFormat ImageFormat
|
|
{
|
|
get
|
|
{
|
|
return ImageFormat.Tiff;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Applies the given processor the current image.
|
|
/// </summary>
|
|
/// <param name="processor">The processor delegate.</param>
|
|
/// <param name="factory">The <see cref="ImageFactory" />.</param>
|
|
public override void ApplyProcessor(Func<ImageFactory, Image> processor, ImageFactory factory)
|
|
{
|
|
base.ApplyProcessor(processor, factory);
|
|
|
|
// Set the property item information from any Exif metadata.
|
|
// We do this here so that they can be changed between processor methods.
|
|
if (factory.PreserveExifData)
|
|
{
|
|
foreach (KeyValuePair<int, PropertyItem> propertItem in factory.ExifPropertyItems)
|
|
{
|
|
try
|
|
{
|
|
factory.Image.SetPropertyItem(propertItem.Value);
|
|
}
|
|
// ReSharper disable once EmptyGeneralCatchClause
|
|
catch
|
|
{
|
|
// Do nothing. The image format does not handle EXIF data.
|
|
// TODO: empty catch is fierce code smell.
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|