mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-25 17:32:07 +01:00
301 lines
8.9 KiB
XML
301 lines
8.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
|
|
<refentry xml:id="function.imagecopyresampled" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>imagecopyresampled</refname>
|
|
<refpurpose>Copie, redimensionne, rééchantillonne une image</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>imagecopyresampled</methodname>
|
|
<methodparam><type>GdImage</type><parameter>dst_image</parameter></methodparam>
|
|
<methodparam><type>GdImage</type><parameter>src_image</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>dst_x</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>dst_y</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>src_x</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>src_y</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>dst_width</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>dst_height</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>src_width</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>src_height</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>imagecopyresampled</function> copie une zone
|
|
rectangulaire de l'image <parameter>src_im</parameter> vers
|
|
l'image <parameter>dst_im</parameter>. Durant la copie,
|
|
la zone est rééchantillonnée de manière à conserver la clarté
|
|
de l'image durant une réduction.
|
|
</para>
|
|
<para>
|
|
En d'autres termes, <function>imagecopyresampled</function> prendra une
|
|
forme rectangulaire <parameter>src_image</parameter> d'une largeur de
|
|
<parameter>src_width</parameter> et d'une hauteur <parameter>src_height</parameter>
|
|
à la position (<parameter>src_x</parameter>,<parameter>src_y</parameter>)
|
|
et le placera dans une zone rectangulaire <parameter>dst_image</parameter>
|
|
d'une largeur de <parameter>dst_width</parameter> et d'une hauteur de
|
|
<parameter>dst_height</parameter> à la position
|
|
(<parameter>dst_x</parameter>,<parameter>dst_y</parameter>).
|
|
</para>
|
|
<para>
|
|
Si les hauteurs et largeurs des source et destination
|
|
diffèrent, l'image copiée sera étirée de manière appropriée.
|
|
Les coordonnées sont celles du coin supérieur gauche.
|
|
<function>imagecopyresampled</function> peut servir à copier
|
|
des zones d'une image vers elle-même, (si <parameter>dst_image</parameter>
|
|
est la même que <parameter>src_image</parameter>) mais si les régions se
|
|
chevauchent, les résultats sont imprévisibles.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>dst_image</parameter></term>
|
|
<listitem>
|
|
<para>&gd.image.destination;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_image</parameter></term>
|
|
<listitem>
|
|
<para>&gd.image.source;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_x</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
X : coordonnées du point de destination.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_y</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Y : coordonnées du point de destination.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_x</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
X : coordonnées du point source.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_y</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Y : coordonnées du point source.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_width</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Largeur de la destination.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_height</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Hauteur de la destination.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_width</parameter></term>
|
|
<listitem>
|
|
<para>&gd.source.width;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_height</parameter></term>
|
|
<listitem>
|
|
<para>&gd.source.height;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>dst_image</parameter> et <parameter>src_image</parameter>
|
|
attendent désormais des instances de <classname>GdImage</classname> ;
|
|
auparavant, des <type>resource</type>s étaient attendues.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple simple</title>
|
|
<para>
|
|
Cet exemple redimensionne une image à la moitié de sa taille originale.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Le fichier
|
|
$filename = 'test.jpg';
|
|
$percent = 0.5;
|
|
|
|
// Content type
|
|
header('Content-Type: image/jpeg');
|
|
|
|
// Calcul des nouvelles dimensions
|
|
list($width, $height) = getimagesize($filename);
|
|
$new_width = $width * $percent;
|
|
$new_height = $height * $percent;
|
|
|
|
// Redimensionnement
|
|
$image_p = imagecreatetruecolor($new_width, $new_height);
|
|
$image = imagecreatefromjpeg($filename);
|
|
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
|
|
|
// Affichage
|
|
imagejpeg($image_p, null, 100);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<mediaobject>
|
|
<imageobject>
|
|
<imagedata fileref="en/reference/image/figures/imagecopyresampled.jpg"/>
|
|
</imageobject>
|
|
</mediaobject>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Redimensionnement proportionnel d'une image</title>
|
|
<para>
|
|
Cet exemple affichera une image avec une largeur ou une hauteur maximale
|
|
de 200 pixels.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Le fichier
|
|
$filename = 'test.jpg';
|
|
|
|
// Définition de la largeur et de la hauteur maximale
|
|
$width = 200;
|
|
$height = 200;
|
|
|
|
// Content type
|
|
header('Content-Type: image/jpeg');
|
|
|
|
// Cacul des nouvelles dimensions
|
|
list($width_orig, $height_orig) = getimagesize($filename);
|
|
|
|
$ratio_orig = $width_orig/$height_orig;
|
|
|
|
if ($width/$height > $ratio_orig) {
|
|
$width = $height*$ratio_orig;
|
|
} else {
|
|
$height = $width/$ratio_orig;
|
|
}
|
|
|
|
// Redimensionnement
|
|
$image_p = imagecreatetruecolor($width, $height);
|
|
$image = imagecreatefromjpeg($filename);
|
|
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
|
|
|
|
// Affichage
|
|
imagejpeg($image_p, null, 100);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<mediaobject>
|
|
<alt>Affichage de l'exemple : Réchantillone une image proportionnellement</alt>
|
|
<imageobject>
|
|
<imagedata fileref="en/reference/image/figures/imagecopyresampled_2.jpg"/>
|
|
</imageobject>
|
|
</mediaobject>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Il y a un problème dû aux limitations de la taille de la palette
|
|
(255 + 1 couleurs différentes). Filtrer ou rééchantillonner une image
|
|
demande plus de 255 couleurs, une approximation est alors utilisée pour
|
|
calculer le nouveau nombre de couleurs. Avec une palette, si une nouvelle
|
|
couleur ne peut être allouée, la couleur la plus proche (en théorie)
|
|
est utilisée. Ce n'est pas toujours la couleur la plus proche visuellement.
|
|
Cela peut générer des problèmes étranges, comme des images blanches.
|
|
Pour éviter ce problème, passez en image TrueColor, comme celle
|
|
générée par la fonction <function>imagecreatetruecolor</function>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>imagecopyresized</function></member>
|
|
<member><function>imagescale</function></member>
|
|
<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
|
|
-->
|