<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.image.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.imagecopyresized.php',
    1 => 'imagecopyresized',
    2 => 'Kopieren und &Auml;ndern der Gr&ouml;&szlig;e eines Bild-Teiles',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD- und Image-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.imagecopyresampled.php',
    1 => 'imagecopyresampled',
  ),
  'next' => 
  array (
    0 => 'function.imagecreate.php',
    1 => 'imagecreate',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/image/functions/imagecopyresized.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecopyresized" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecopyresized</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecopyresized</span> &mdash; <span class="dc-title">Kopieren und Ändern der Größe eines Bild-Teiles</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecopyresized-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecopyresized</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span> <code class="parameter">$dst_image</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span> <code class="parameter">$src_image</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$dst_x</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$dst_y</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$src_x</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$src_y</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$dst_width</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$dst_height</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$src_width</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$src_height</code></span><br>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>imagecopyresized()</strong></span> kopiert einen rechteckigen
   Ausschnitt eines Bildes in ein anderes Bild.
   <code class="parameter">dst_image</code> gibt das Zielbild,
   <code class="parameter">src_image</code> gibt die Bildquelle an.
  </p>
  <p class="para">
   Mit anderen Worten, <span class="function"><strong>imagecopyresized()</strong></span> nimmt
   einen rechteckigen Ausschnitt von <code class="parameter">src_image</code> der Breite
   <code class="parameter">src_width</code> and Höhe <code class="parameter">src_height</code> von
   Position (<code class="parameter">src_x</code>,<code class="parameter">src_y</code>)
   und platziert diesen in einem rechteckigen Bereich in <code class="parameter">dst_image</code>
   mit der Breite <code class="parameter">dst_width</code> and Höhe <code class="parameter">dst_height</code>
   an der Position (<code class="parameter">dst_x</code>,<code class="parameter">dst_y</code>).
  </p>
  <p class="para">
   Unterscheiden sich die Angaben der Quelle und des Ziels bezogen auf
   die Koordinaten, Höhe oder Breite, wird das Teilbild entsprechend
   gedehnt oder geschrumpft. Die Koordinaten beziehen sich auf die
   linke obere Ecke. Sie können hiermit auch Teilbilder innerhalb
   ein- und desselben Bildes kopieren, sofern
   <code class="parameter">dst_image</code> und <code class="parameter">src_image</code>
   gleich sind. Falls sich dabei aber die kopierten Teile überlappen,
   führt das zu unvorhersehbaren Ergebnissen.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecopyresized-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">dst_image</code></dt>
     <dd>
      <p class="para">Ressource des Zielbildes.</p>
     </dd>
    
    
     <dt><code class="parameter">src_image</code></dt>
     <dd>
      <p class="para">Ressource des Quellbildes.</p>
     </dd>
    
    
     <dt><code class="parameter">dst_x</code></dt>
     <dd>
      <p class="para">
       x-Koordinate des Zielrechtecks.
      </p>
     </dd>
    
    
     <dt><code class="parameter">dst_y</code></dt>
     <dd>
      <p class="para">
       y-Koordinate des Zielrechtecks.
      </p>
     </dd>
    
    
     <dt><code class="parameter">src_x</code></dt>
     <dd>
      <p class="para">
       x-Koordinate des Quellrechtecks.
      </p>
     </dd>
    
    
     <dt><code class="parameter">src_y</code></dt>
     <dd>
      <p class="para">
       y-Koordinate des Quellrechtecks.
      </p>
     </dd>
    
    
     <dt><code class="parameter">dst_width</code></dt>
     <dd>
      <p class="para">
       Breite des Zielrechtecks.
      </p>
     </dd>
    
    
     <dt><code class="parameter">dst_height</code></dt>
     <dd>
      <p class="para">
       Höhe des Zielrechtecks.
      </p>
     </dd>
    
    
     <dt><code class="parameter">src_width</code></dt>
     <dd>
      <p class="para">Breite der Quelle.</p>
     </dd>
    
    
     <dt><code class="parameter">src_height</code></dt>
     <dd>
      <p class="para">Höhe der Quelle.</p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecopyresized-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt immer <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagecopyresized-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">dst_image</code> und <code class="parameter">src_image</code> erwarten jetzt
       <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>-Instanzen;
       zuvor wurde eine <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> erwartet.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecopyresized-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Ein Bild skalieren</strong></p>
    <div class="example-contents"><p>
     Dieses Beispiel zeigt ein Bild in halber Größe an.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Datei und Faktor der Größenänderung<br /></span><span style="color: #0000BB">$filename </span><span style="color: #007700">= </span><span style="color: #DD0000">'test.jpg'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$percent </span><span style="color: #007700">= </span><span style="color: #0000BB">0.5</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Typ der Ausgabe<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type: image/jpeg'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Neue Größe berechnen<br /></span><span style="color: #007700">list(</span><span style="color: #0000BB">$width</span><span style="color: #007700">, </span><span style="color: #0000BB">$height</span><span style="color: #007700">) = </span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$newwidth </span><span style="color: #007700">= </span><span style="color: #0000BB">$width </span><span style="color: #007700">* </span><span style="color: #0000BB">$percent</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$newheight </span><span style="color: #007700">= </span><span style="color: #0000BB">$height </span><span style="color: #007700">* </span><span style="color: #0000BB">$percent</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Bild laden<br /></span><span style="color: #0000BB">$thumb </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">$newwidth</span><span style="color: #007700">, </span><span style="color: #0000BB">$newheight</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$source </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefromjpeg</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Skalieren<br /></span><span style="color: #0000BB">imagecopyresized</span><span style="color: #007700">(</span><span style="color: #0000BB">$thumb</span><span style="color: #007700">, </span><span style="color: #0000BB">$source</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">$newwidth</span><span style="color: #007700">, </span><span style="color: #0000BB">$newheight</span><span style="color: #007700">, </span><span style="color: #0000BB">$width</span><span style="color: #007700">, </span><span style="color: #0000BB">$height</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Ausgabe<br /></span><span style="color: #0000BB">imagejpeg</span><span style="color: #007700">(</span><span style="color: #0000BB">$thumb</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt
eine ähnliche Ausgabe wie:</p></div>
    <div class="mediaobject">
     
     <div class="imageobject">
      <img src="images/21009b70229598c6a80eef8b45bf282b-imagecopyresized.jpg" alt="Ausgabe des Beispiels : Ein Bild skalieren" width="47" height="25" />
     </div>
    </div>
    <div class="example-contents"><p>
     Das Bild wird in halber Größe ausgegeben, allerdings könnten mit
     Hilfe der Funktion <span class="function"><a href="function.imagecopyresampled.php" class="function">imagecopyresampled()</a></span> Ergebnisse
     besserer Qualität erzielt werden.
    </p></div>
   </div>
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.imagecopyresized-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Es gibt ein Problem bei Verwendung von limitierten Farbpaletten
    (255+1 Farben). Resampling und Filterung von Bildern benötigt in der
    Regel mehr als 255 Farben und eine Art der Annäherung wird zur
    Berechnung des neu resampleten Pixels und dessen Farbwertes verwendet.
    Bei einem palettenbasierten Bild wird zuerst versucht eine neue Farbe
    zu allokieren, wenn dies fehlschlägt wird der theoretisch nächst
    gelegene Farbwert aus der Palette verwendet. Dies ist aber nicht immer
    der Wert der farblich am nächsten ist. Dies kann zu eigenartigen
    Ergebnissen wie leeren (oder scheinbar leeren) Bildern führen.
    Um dieses Problem zu vermeiden, sollte ein Truecolor-Bild als
    Zielbild verwendet werden, welches z. B. mit der Funktion
    <span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span> erstellt werden kann.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagecopyresized-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagecopyresampled.php" class="function" rel="rdfs-seeAlso">imagecopyresampled()</a> - Copy and resize part of an image with resampling</span></li>
   <li><span class="function"><a href="function.imagescale.php" class="function" rel="rdfs-seeAlso">imagescale()</a> - Scale an image using the given new width and height</span></li>
   <li><span class="function"><a href="function.imagecrop.php" class="function" rel="rdfs-seeAlso">imagecrop()</a> - Crop an image to the given rectangle</span></li>
  </ul>
 </div>

</div><?php manual_footer($setup); ?>