DEXTUpload.NET Professional
menu toggleリファレンス > DEXTUpload.NET > ImageProc

DEXTUpload.NET
Class ImageProc

サポートされる最小バージョン
5.0.0.0
最小サポート環境
.NET Framework 4.0
説明

DEXTUpload.NET Professionalコンポーネント製品は、Webアプリケーション環境で簡単な画像処理をサポートするためにWindows GDI +を使用したユーティリティクラスを提供する。

「ImageProc」クラスは、GDI +を使用するため、サーバーOSの場合、GDI +がサポート可能な環境でのみ動作する。

注意)「ImageProc」クラスは、基本的なレベルの画像処理だけをサポートするので、複雑な計算や、高速処理速度を提供しない。したがって、高水準の処理が必要な場合には、画像の専門ライブラリを使用することをお勧めします。

var source = new FileInfo("source.jpg");

//イメージオブジェクトを得る。
var img = ImageProc.GetImage(source);

//メタデータを得る。
var metadata = ImageProc.GetMetadata(source);

//ファイルとして保存する。
ImageProc.SaveImage(img, new FileInfo("output.jpg"), new ImageSaveOption { IsOverwrite = true });

// JPEGファイルをPNGファイルとして形式を変換して保存する。
ImageProc.ConvertImage(source, new FileInfo("output.png"), new ImageSaveOption { OutputFormat = ImageFormat.Png });

//画像をリサイズする。
var img01 = ImageProc.Resize(img, new ResizingOption { Width = 50, Height = 20, Unit = ImageResizeUnit.Percentage });

//画像をフィッティングする。
var img02 = ImageProc.Fit(img, new FittingOption { Width = 100, Height = 200, Fit = ImageFitOption.Uniform });
形式
public static class ImageProc
メソッド

GetImage

  • 画像ファイルを読み込み、「System.Drawing.Image」オブジェクトを生成して返します。

  • 形式

    public static Image GetImage(string sourcePath)
    public static Image GetImage(FileInfo source)
  • パラメータ

    名前 形式 説明
    sourcePath System.String イメージファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    source System.IO.FileInfo 画像情報を持つオブジェクトです。
  • リターン

    画像情報を持つ「System.Drawing.Image」オブジェクトだ。

GetMetadata

  • メタデータをサポートしている形式を持ったイメージからメタデータを抽出して返します。

    TIFF、JPEG、PNG、EXIFイメージ形式でメタデータをインポートすることができ、他の形式には対応していない。

  • 形式

    public static Metadata GetMetadata(Image imgSource)
    public static Metadata GetMetadata(FileInfo source)
    public static Metadata GetMetadata(string sourcePath)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image メタデータを抽出するオブジェクトである。
    source System.IO.FileInfo メタデータを抽出する画像ファイルのパス情報を持つオブジェクトです。
    sourcePath System.String メタデータを抽出する画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
  • リターン

    画像から抽出されたメタデータ情報を持つ「DEXTUpload.NET.Metadata」オブジェクトだ。

SaveImage

  • 「System.Drawing.Image」オブジェクトを別の画像形式で保存する。

  • 形式

    public static string SaveImage(Image imgSource, FileInfo target, ImageSaveOption option)
    public static string SaveImage(Image imgSource, string targetPath, ImageSaveOption option)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 他の画像形式で保存するオブジェクトである。
    target System.IO.FileInfo 保存先のパス情報を持つオブジェクトです。
    targetPath System.String 保存するファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    option DEXTUpload.NET.ImageSaveOption イメージファイルの保存オプションの情報を持つオブジェクトです。
  • リターン

    保存された画像ファイルのローカル・オペレーティング・システムのパスを返す。

ConvertImage

  • 元の画像ファイルを別の画像形式で保存する。

  • 形式

    public static string ConvertImage(FileInfo source, FileInfo target, ImageSaveOption option)
    public static string ConvertImage(string sourcePath, string targetPath, ImageSaveOption option)
  • パラメータ

    名前 形式 説明
    source System.IO.FileInfo 元の画像ファイルのパス情報を持つオブジェクトです。
    target System.IO.FileInfo 保存先のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    targetPath System.String 保存するファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    option DEXTUpload.NET.ImageSaveOption イメージファイルの保存オプションの情報を持つオブジェクトです。
  • リターン

    保存された画像ファイルのローカル・オペレーティング・システムのパスを返す。

Overlay

  • 元の画像の上に別の画像やテキストをオーバーレイした画像を生成する。

  • 形式

    public static Image Overlay(Image imgSource, Image imgTarget, OverlayOption option)
    public static Image Overlay(FileInfo source, FileInfo target, OverlayOption option)
    public static Image Overlay(string sourcePath, string targetPath, OverlayOption option)
    public static Image Overlay(Image imgSource, string text, Font font, Color fontColor, OverlayOption option)
    public static Image Overlay(FileInfo source, string text, Font font, Color fontColor, OverlayOption option)
    public static Image Overlay(string sourcePath, string text, Font font, Color fontColor, OverlayOption option)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    imgTarget System.Drawing.Image 対象画像オブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    target System.IO.FileInfo ターゲットイメージのパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    targetPath System.String 対象画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    text System.String オーバーレイするテキストである。
    font System.Drawing.Font テキストのフォントスタイル情報を持つオブジェクトです。
    fontColor System.Drawing.Color テキストの色情報を持つオブジェクトです。
    option DEXTUpload.NET.OverlayOption オーバーレイ処理情報を持つオブジェクトです。
  • リターン

    オーバーレイが適用されたSystem.Drawing.Imageオブジェクトだ。

Pattern

  • 元の画像の上にパターン画像やパターンとして使用するテキストを碁盤のように表示されてオーバーレイした画像を生成する。

  • 形式

    public static Image Pattern(Image imgSource, Image imgPattern, PatternOption option)
    public static Image Pattern(FileInfo source, FileInfo pattern, PatternOption option)
    public static Image Pattern(string sourcePath, string patternPath, PatternOption option)
    public static Image Pattern(Image imgSource, string text, Font font, Color fontColor, PatternOption option)
    public static Image Pattern(FileInfo source, string text, Font font, Color fontColor, PatternOption option)
    public static Image Pattern(string sourcePath, string text, Font font, Color fontColor, PatternOption option)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    imgPattern System.Drawing.Image パターンとして使用する画像オブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。.
    pattern System.IO.FileInfo パターンとして使用する画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    patternPath System.String パターンとして使用する画像のファイルパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    text System.String パターンとして使用するテキストです。
    font System.Drawing.Font テキストのフォントスタイル情報を持つオブジェクトです。
    fontColor System.Drawing.Color テキストの色情報を持つオブジェクトです。
    option DEXTUpload.NET.PatternOption パターンをオーバーレイする情報を持つオブジェクトです。
  • リターン

    パターンが適用されたSystem.Drawing.Imageオブジェクトだ。

Resize

  • 元の画像の縦、横のサイズをリサイズ(resizing)した画像を生成する。

  • 形式

    public static Image Resize(Image imgSource, ResizingOption option)
    public static Image Resize(FileInfo source, ResizingOption option)
    public static Image Resize(string sourcePath, ResizingOption option)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    option DEXTUpload.NET.ResizingOption サイズ変更オプションの情報を持つオブジェクトです。
  • リターン

    リサイズされたSystem.Drawing.Imageオブジェクトだ。

Fit

  • 元の画像指定したフレームに合うようにフィッティング(fi​​tting)した画像を生成する。

  • 形式

    public static Image Fit(Image imgSource, FittingOption option)
    public static Image Fit(FileInfo source, FittingOption option)
    public static Image Fit(string sourcePath, FittingOption option)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    option DEXTUpload.NET.FittingOption 継手オプション情報を持つオブジェクトです。
  • リターン

    近似System.Drawing.Imageオブジェクトだ。

Rotate

  • 元の画像を回転した画像を生成する。

  • 形式

    public static Image Rotate(Image imgSource, double degree, Color backgroundColor)
    public static Image Rotate(FileInfo source, double degree, Color backgroundColor)
    public static Image Rotate(string sourcePath, double degree, Color backgroundColor)
    public static Image Rotate(Image imgSource, RotationMethod method)
    public static Image Rotate(FileInfo source, RotationMethod method)
    public static Image Rotate(string sourcePath, RotationMethod method)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    degree System.Double 画像を回転させる角度である。
    backgroundColor System.Drawing.Color 画像を回転させた後に生じる余白を埋める色を表すオブジェクトである。
    method DEXTUpload.NET.RotationMethod 回転方法を示す列挙型のメンバーである。
  • リターン

    回転されたSystem.Drawing.Imageオブジェクトだ。

Flip

  • 元の画像を座標軸を基準に反転した画像を生成する。

  • 形式

    public static Image Flip(Image imgSource, FlipMethod method)
    public static Image Flip(FileInfo source, FlipMethod method)
    public static Image Flip(string sourcePath, FlipMethod method)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    method DEXTUpload.NET.FlipMethod 画像を反転する方法を示す列挙型のメンバーである。
  • リターン

    反転したSystem.Drawing.Imageオブジェクトだ。

Crop

  • 元の画像の一部の領域だけを別に切り出した(cropping)新しい画像を生成する。

  • 形式

    public static Image Crop(Image imgSource, int x, int y, int width, int height)
    public static Image Crop(FileInfo source, int x, int y, int width, int height)
    public static Image Crop(string sourcePath, int x, int y, int width, int height)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    x System.Int32 トリミング矩形領域のx軸の位置を指定する。
    y System.Int32 トリミング矩形領域のy軸の位置を指定する。
    width System.Int32 トリミング矩形領域の水平方向のサイズを指定する。
    height System.Int32 トリミング矩形領域の縦方向のサイズを指定する。
  • リターン

    切り取ったSystem.Drawing.Imageオブジェクトだ。

HasAnimationFrame (5.2.0.0バージョンからサポート)

  • 元の画像が時間ごとのフレームの情報を持っているかどうかを返します。

  • 形式

    public static bool HasAnimationFrame(Image imgSource)
    public static bool HasAnimationFrame(FileInfo source)
    public static bool HasAnimationFrame(string sourcePath)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
  • リターン

    時間ごとのフレーム情報を持っている場合true、または「false」である。

GetAnimationFrameCount (5.2.0.0バージョンからサポート)

  • 元の画像が時間ごとのフレーム情報を持っている場合は、フレームの数を返します。

    時間ごとのフレーム情報を持っていない場合は、エラーが発生するので、「HasAnimationFrame」メソッドを使用して時間ごとのフレーム情報を持っているか確認することができる。

  • 形式

    public static int GetAnimationFrameCount(Image imgSource)
    public static int GetAnimationFrameCount(FileInfo source)
    public static int GetAnimationFrameCount(string sourcePath)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
  • リターン

    フレーム本数だ。

GetAnimationFrame (5.2.0.0バージョンからサポート)

  • 元の画像が時間ごとのフレーム情報を持っている場合は、フレーム番号に対応するフレームを「System.Drawing.Image」オブジェクトとして生成して返します。

    アニメーションGIFファイルの場合、特定のフレームを抽出する用途に使用することができる。

  • 形式

    public static Image GetAnimationFrame(Image imgSource, int frameIndex)
    public static Image GetAnimationFrame(FileInfo source, int frameIndex)
    public static Image GetAnimationFrame(string sourcePath, int frameIndex)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    frameIndex System.Int32 抽出しようとするフレーム番号である。
  • リターン

    抽出されたフレーム情報を持つSystem.Drawing.Imageオブジェクトだ。

ExtractAnimationFrame (5.2.0.0バージョンからサポート)

  • 元の画像が時間ごとのフレーム情報を持っている場合は、フレーム番号に対応するフレームを「System.Drawing.Image」オブジェクトとして生成して返します。

    アニメーションGIFファイルの場合、特定のフレームを抽出する用途に使用することができる。

  • 形式

    public static string ExtractAnimationFrame(Image imgSource, int frameIndex, FileInfo target, bool overwrite option)
    public static string ExtractAnimationFrame(FileInfo source, int frameIndex, FileInfo target, bool overwrite option)
    public static string ExtractAnimationFrame(string sourcePath, int frameIndex, FileInfo target, bool overwrite option)
    public static string ExtractAnimationFrame(Image imgSource, int frameIndex, string targetPath, bool overwrite option)
    public static string ExtractAnimationFrame(FileInfo source, int frameIndex, string targetPath, bool overwrite option)
    public static string ExtractAnimationFrame(string sourcePath, int frameIndex, string targetPath, bool overwrite option)
  • パラメータ

    名前 形式 説明
    imgSource System.Drawing.Image 元の画像のオブジェクトである。
    source System.IO.FileInfo 元の画像のパス情報を持つオブジェクトです。
    sourcePath System.String 元の画像ファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    frameIndex System.Int32 抽出しようとするフレーム番号である。
    target System.IO.FileInfo 保存するファイルのパス情報を持つオブジェクトです。
    targetPath System.String 保存するファイルのパス(ローカルオペレーティングシステムのパスまたはWebアプリケーションのサブパス)である。
    overwrite System.Boolean ファイルを保存するときは、先に同じ名前のファイルがある場合は、上書きするかどうかを示す。
  • リターン

    抽出されたフレーム情報が格納されたファイルのパス(ローカルオペレーティングシステムのパス)である。