Image

非推奨

このタスクは非推奨となりました。Java Advanced Image APIは、Java 9で削除された内部クラスに依存しているためです。代わりにImageIOタスクを使用してください。

説明

一連のファイルに対して画像処理のチェーンを適用します。

Sun製のJava Advanced Image APIが必要です。

使用されるデータ型の概要
ImageOperation class diagram A diagram of Ant DataType classes used by Image task. org.apache.tools.ant.types.DataType ImageOperation instructions : Vector addRotate(Rotate : instr) addDraw(Draw : instr) addText(Text : instr) addScale(Scale : instr) The setType() method forces type to one of the values of java.awt.geom.Arc2D: open = Arc2D.OPEN pie = Arc2D.PIE chord = Arc2D.CHORD Parameter is not case-sensitive. BasicShape stroke_width : int = 0 fill : String = "transparent" stroke : String = "black" TransformOperation executeTransformOperation(PlanarImage img) : PlanarImage addRectangle(Rectangle instr) <<interface>> DrawOperation executeDrawOperation() : PlanarImage The implementing class uses ColorMapper to evaluate the color. Only the values defined in ColorMapper are used. ColorMapper COLOR_BLACK : String = "black" COLOR_BLUE : String = "blue" COLOR_CYAN : String = "cyan" COLOR_DARKGRAY : String = "darkgray" COLOR_GRAY : String = "gray" COLOR_LIGHTGRAY : String = "lightgray" COLOR_DARKGREY : String = "darkgrey" COLOR_GREY : String = "grey" COLOR_LIGHTGREY : String = "lightgrey" COLOR_GREEN : String = "green" COLOR_MAGENTA : String = "magenta" COLOR_ORANGE : String = "orange" COLOR_PINK : String = "pink" COLOR_RED : String = "red" COLOR_WHITE : String = "white" COLOR_YELLOW : String = "yellow" Text string : String = "" font : String = "Arial" point : int = 10 bold : boolean = false color : String = "black" italic : boolean = false Rotate angle : float = 0.0F Scale width : String = "100%" height : String = "100%" keepProportions : boolean = false Draw xloc : int = 0 yloc : int = 0 addEllipse(Ellipse elip) addArc(Arc arc) Rectangle height : int = 0 width : int = 0 archeight : int = 0 arcwidth : int = 0 Ellipse height : int = 0 width : int = 0 Arc height : int = 0 width : int = 0 start : int = 0 stop : int = 0 type : enumerated = open

パラメータ

属性 説明 必須
failonerror ブール値。 falseの場合、エラーをアウトプットに記録しますが、処理を続行します。 いいえ; デフォルトはtrue
srcdir 画像を含むディレクトリ。 はい、ネストされたfilesetを使用しない限り
encoding 画像エンコーディングの種類。
有効な値(大文字と小文字は区別されません)は:jpgjpegtiftiff
いいえ; デフォルトはjpeg
overwrite ブール値。名前の競合がある場合にファイルを上書きするかどうかを設定します。 いいえ; デフォルトはfalse
gc ブール値。処理された各画像の後でガベージコレクションを有効にします。 いいえ; デフォルトはfalse
destdir 結果の画像が格納されるディレクトリ。 srcdirの値をデフォルトとして使用します。
includes 含める必要があるファイルのパターンのカンマまたはスペース区切りのリスト。 いいえ; デフォルトはすべて(**)
includesfile ファイル名。このファイルの各行は、インクルードパターンとして扱われます。 いいえ
excludes 除外する必要があるファイルのパターンのカンマまたはスペース区切りのリスト。 defaultexcludesnoの場合、デフォルトの除外または何も除外しません。
excludesfile ファイル名。このファイルの各行は、除外パターンとして扱われます。 いいえ
defaultexcludes デフォルトの除外を使用するかどうかを示します(yes|no)。 いいえ; デフォルトはyes
caseSensitive ブール値。ファイルシステムの大文字と小文字の区別を設定します。 いいえ; デフォルトはfalse
followSymlinks ブール値。シンボリックリンクをたどるかどうかを設定します。 いいえ; デフォルトはtrue

ネストされた要素として指定されたパラメータ

このタスクは暗黙的なFileSetを形成し、<fileset>のほとんどの属性と、ネストされた<include><exclude><patternset>要素をサポートしています。

次のImageOperationオブジェクトは、ネストされた要素として指定できます:RotateScaleDraw

Rotate

チェーンにRotate ImageOperationを追加します。

パラメータ
属性 説明 必須
angle 浮動小数点値。回転角度を度単位で設定します。 いいえ; デフォルトは0.0F

Scale

チェーンにScale ImageOperationを追加します。

パラメータ
属性 説明 必須
proportions どの寸法を基準に比率を維持するかを設定します。有効な値は
  • ignore—寸法を個別に扱います。
  • height—幅に基づいて比率を維持します。
  • width—高さに基づいて比率を維持します。
  • cover—比率を維持し、指定された寸法に収まるようにします。
  • fit—比率を維持し、指定された寸法を覆うようにします。
いいえ; デフォルトはignore
width 画像の幅を整数(ピクセル)または%で設定します。 いいえ; デフォルトは100%
height 画像の高さを整数(ピクセル)または%で設定します。 いいえ; デフォルトは100%

Draw

チェーンにDraw ImageOperationを追加します。DrawOperation DataTypeオブジェクトは、Drawオブジェクト内にネストできます。

パラメータ
属性 説明 必須
xloc ネストされた画像要素を描画するX座標。 いいえ; デフォルトは0
yloc ネストされた画像要素を描画するY座標。 いいえ; デフォルトは0

ネストされた要素の説明については、ImageIOタスクのドキュメントを参照してください。

mapper

Apache Ant 1.8.0以降

ネストされたmapper要素を使用して、ファイル名の変換を定義できます。<image>によって使用されるデフォルトのmapperは、identity mapperです。

mapper要素の代わりにfilenamemapperタイプを使用することもできます。

画像のサムネイルを作成し、画像が縦向きか横向きかに関係なく、すべてが160×160ピクセルのサイズに収まるようにします。

<image destdir="samples/low" overwrite="yes">
    <fileset dir="samples/full">
        <include name="**/*.jpg"/>
    </fileset>
    <scale width="160" height="160" proportions="fit"/>
</image>

src内のすべてのPNGファイルの、比率を維持した40ピクセルのサイズのサムネイルを作成し、srcに保存します。

<image srcdir="src" includes="*.png">
    <scale proportions="width" width="40"/>
</image>

上記と同じですが、結果をdestに保存します。

<image srcdir="src" destdir="dest" includes="*.png">
    <scale proportions="width" width="40"/>
</image>

上記と同じですが、元のファイル名にscaled-をプレフィックスとして付けたファイルに結果を保存します。

<image srcdir="src" destdir="dest" includes="*.png">
    <scale proportions="width" width="40"/>
    <globmapper from="*" to="scaled-*"/>
</image>