mirror of
https://github.com/php/doc-ja.git
synced 2026-04-26 17:38:12 +02:00
241 lines
8.0 KiB
XML
241 lines
8.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: takagi Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
|
|
<refentry xml:id="function.imagecropauto" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>imagecropauto</refname>
|
|
<refpurpose>利用可能なモードを指定して、画像を自動的にクロップする</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>GdImage</type><type>false</type></type><methodname>imagecropauto</methodname>
|
|
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer><constant>IMG_CROP_DEFAULT</constant></initializer></methodparam>
|
|
<methodparam choice="opt"><type>float</type><parameter>threshold</parameter><initializer>0.5</initializer></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>color</parameter><initializer>-1</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
指定した <parameter>mode</parameter> にしたがって、画像を自動的にクロップします。
|
|
</para>
|
|
|
|
&warn.undocumented.func;
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
&gd.image.description;
|
|
<varlistentry>
|
|
<term><parameter>mode</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
以下の定数のいずれか。
|
|
</para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><constant>IMG_CROP_DEFAULT</constant></term>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>IMG_CROP_TRANSPARENT</constant> と同じです。
|
|
PHP 7.4.0 より前のバージョンでは、
|
|
PHP にバンドルされた libgd は、
|
|
画像に透過色がない場合に <constant>IMG_CROP_SIDES</constant>
|
|
にフォールバックしていました。
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><constant>IMG_CROP_TRANSPARENT</constant></term>
|
|
<listitem>
|
|
<simpara>
|
|
透過色の背景をクロップします。
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><constant>IMG_CROP_BLACK</constant></term>
|
|
<listitem>
|
|
<simpara>
|
|
黒の背景をクロップします。
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><constant>IMG_CROP_WHITE</constant></term>
|
|
<listitem>
|
|
<simpara>
|
|
白の背景をクロップします。
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><constant>IMG_CROP_SIDES</constant></term>
|
|
<listitem>
|
|
<simpara>
|
|
画像の四隅から、クロップする背景色を検出します。
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><constant>IMG_CROP_THRESHOLD</constant></term>
|
|
<listitem>
|
|
<simpara>
|
|
<parameter>threshold</parameter> と
|
|
<parameter>color</parameter> を用いてクロップします。
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>threshold</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
画像の色とクロップする色を比較する際に用いる許容誤差を、パーセントで指定します。
|
|
色の違いを判断する際には、RGBキューブ内での距離を用います。
|
|
</para>
|
|
<para>
|
|
<constant>IMG_CROP_THRESHOLD</constant> モードのときにだけ利用します。
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
PHP 7.4.0 より前のバージョンでは、
|
|
PHP にバンドルされていた libgd はやや異なるアルゴリズムを用いていました。
|
|
なので、同じ <parameter>threshold</parameter> を渡しても
|
|
システムの libgd と PHP にバンドルされた libgd とは異なる結果が生成されていました。
|
|
</simpara>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>color</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
RGB値あるいはパレットインデックスを指定します。
|
|
</para>
|
|
<para>
|
|
<constant>IMG_CROP_THRESHOLD</constant> モードのときにだけ利用します。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
成功した場合にクロップ後の画像オブジェクトを返します。
|
|
&return.falseforfailure;
|
|
画像全体がクロップされてしまった場合にも &false; を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&gd.changelog.image-param;
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
成功時には、
|
|
この関数は <classname>GDImage</classname>
|
|
クラスのインスタンスを返すようになりました。
|
|
これより前のバージョンでは、
|
|
<type>resource</type> を返していました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.4.0</entry>
|
|
<entry>
|
|
PHP にバンドルされた imagecropauto() の振る舞いは、
|
|
システムにインストールされる libgd のそれと同じになりました。
|
|
つまり、<constant>IMG_CROP_DEFAULT</constant>
|
|
が <constant>IMG_CROP_SIDES</constant> にフォールバックすることはなくなり、
|
|
しきい値によるクロップは、
|
|
システムにインストールされる libgd のアルゴリズムと同じものを使うようになりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.4.0</entry>
|
|
<entry>
|
|
<parameter>mode</parameter> パラメータのデフォルト値が
|
|
<constant>IMG_CROP_AUTO</constant> に変更されました。
|
|
これより前のバージョンでは、デフォルト値は
|
|
<literal>-1</literal> で、<constant>IMG_CROP_DEFAULT</constant> に対応しています。
|
|
しかし、<literal>-1</literal> を渡すのは非推奨になりました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>自動クロップの適切な処理</title>
|
|
<para>
|
|
戻り値のところで説明したとおり、全部クロップしてしまったときに
|
|
<function>imagecropauto</function> が返す値は &false; となります。
|
|
この例では、クロップする部分がある場合にだけ画像オブジェクト
|
|
<literal>$im</literal> を自動クロップします。
|
|
それ以外の場合は、元の画像をそのまま使います。
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$cropped = imagecropauto($im, IMG_CROP_DEFAULT);
|
|
if ($cropped !== false) { // 新しい画像オブジェクトが戻された場合にだけ
|
|
$im = $cropped; // クロップ後の画像を $im に代入します
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>imagecrop</function></member>
|
|
</simplelist>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|