15.4. 画像分割...

15.4.1. 概観

図17.412 画像分割フィルターの使用例

「画像分割」フィルターの使用例

元画像 (ガイドつき)

「画像分割」フィルターの使用例

画像分割フィルター適用


This filter is a simple and easy to use helper for creating sensitive images to be used in HTML files. The filter slices up the source image (like the Slice Using Guides command does) along its horizontal and vertical guides, and produces a set of sub-images. At the same time it creates a piece of HTML code for a table saved in a text file. Every table cell contains one part of the image. The text file should then be embedded in an HTML document.

繰り返しますがこのフィルターは実にとても単純な支援ツールです。 書き出される HTML コードは精々次の例のようなものになります。

例17.1 単純な画像分割フィルターの出力例

<table cellpadding="0" border="0" cellspacing="0">
  <tr>
    <td><img alt="" src="slice_0_0.png"/></td>
    <td><img alt="" src="slice_0_1.png"/></td>
  </tr>
  <tr>
    <td><img alt="" src="slice_1_0.png"/></td>
    <td><img alt="" src="slice_1_1.png"/></td>
  </tr>
</table>
        

生成される HTML コード。 style属性は省かれている。


画像にガイド (見当線) がないときはフィルターは何も実行しません。 もちろんガイドが単に隠されているだけならフィルターは作動します。

[ヒント] ヒント

The ImageMap filter is a much more powerful and sophisticated tool for creating sensitive images. (But it is also much more complex.)

15.4.2. Activating the Filter

This filter is found in the image window menu under FiltersWebSlice….

15.4.3. オプション

図17.413 画像分割のオプション

「画像分割」のオプション

ほとんどのオプションの意味は見てのとおりですが、 あえて説明します。

HTML ドキュメントを生成する場所

生成された HTML ファイルと画像ファイルの保管場所です。 初期状態では現在の作業ディレクトリーにこれらのファイルが保管されます。 記入欄の右端の三角形のボタンをクリックすると他のフォルダーを辿れる引き出しメニューが出てきます。

HTML ドキュメント名

生成される HTML コードを収めたファイルの名前です。 記入欄で他の名前も指定できます。

画像ファイル名のプレフィクス

The name of an image file produced by this filter is prefix_i_k.ext, where prefix is that part of the filename which you can freely select using the textbox to the right, by default: slice. (i and k are the numbers of the row and the column, each starting with 0; .ext is the filename extension depending on the selected Image format.)

This option is particularly useful when you want to create JavaScript for onmouseover and clicked and need different sets of images.

エクスポート画像のファイル形式

You can choose to create image files in the GIF, JPG, or PNG file format.

画像を別フォルダーにエクスポート, エクスポート先のフォルダー名

画像を別フォルダーにエクスポート させる場合は画像を収めるフォルダーが無ければ作成されます。 この場合の既定の保管先フォルダーの名前は images ですが、 エクスポート先のフォルダー名 の記入欄で他のフォルダー名が指定できます。

例17.2 画像用に別フォルダーを使った例

画像を別フォルダーにエクスポート した結果


テーブル要素間の間隔

この数値は HTML テーブルのセル同士の間隔を指定するcelllspacing属性値になります。 値の範囲は 0 ピクセルから 15 ピクセルまでです。 ここに正の整数を設定すると縦や横のガイドはこの太さをした平行線で現れます。

例17.3 テーブル要素間の間隔

関連している HTML コードの抜粋


ここで気をつけていただきたいことは、 この間隔を拡げても画像の規模は大きくならないことです。 むしろ HTML テーブルで揃えられた画像は消しゴムツールで縦横の線状に消されたように見えることでしょう。

JavaScript for onmouseover and clicked

このオプションを有効にするとこのフィルターは Javascript コードを追加します。 HTML の場合と同じく生成されたままの状態では何の効果もありませんが、 動的機能を追加してゆくには良好な手掛かりとなります。 この Javascript コードはonmouseoverのようなイベントを扱う関数に利用できます。

例17.4 JavaScript コードの抜粋

function exchange (image, images_array_name, event)
  {
    name = image.name;
    images = eval (images_array_name);

    switch (event)
      {
        case 0:
          image.src = images[name + "_plain"].src;
          break;
        case 1:
          image.src = images[name + "_hover"].src;
          break;
        case 2:
          image.src = images[name + "_clicked"].src;
          break;
        case 3:
          image.src = images[name + "_hover"].src;
          break;
      }
  }
              

周辺部の画像切り替えを省略

When disabled, the filter will add a <a href="#"> ... </a> hyperlink stub to every table cell. When enabled (this is the default) and there are at least two horizontal or two vertical guides, the filter will not add a hyperlink stub to the first and last cell in a column or row. This may be useful when you have an image with border and you don't want to make the border sensitive.

例17.5 外周部の画像片にはアンカータグを省略 (簡易 HTML コード)

<table cellpadding="0" border="0" cellspacing="0">
  <tr>
    <td><img alt="" src="images/slice_0_0.png"/></td>
    <td><img alt="" src="images/slice_0_1.png"/></td>
    <td><img alt="" src="images/slice_0_2.png"/></td>
    <td><img alt="" src="images/slice_0_3.png"/></td>
  </tr>
  <tr>
    <td><img alt="" src="images/slice_1_0.png"/></td>
    <td><a href="#"><img alt="" src="images/slice_1_1.png"/></a></td>
    <td><a href="#"><img alt="" src="images/slice_1_2.png"/></a></td>
    <td><img alt="" src="images/slice_1_3.png"/></td>
  </tr>
  <tr>
    <td><img alt="" src="images/slice_2_0.png"/></td>
    <td><img alt="" src="images/slice_2_1.png"/></td>
    <td><img alt="" src="images/slice_2_2.png"/></td>
    <td><img alt="" src="images/slice_2_3.png"/></td>
  </tr>
</table>
              

内側のセルだけ (空の) ハイパーリンクがかかる。