Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 7088

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>imagecopyresampled</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Imagens, Funções de"
HREF="ref.image.html"><LINK
REL="PREVIOUS"
TITLE="imagecopymergegray"
HREF="function.imagecopymergegray.html"><LINK
REL="NEXT"
TITLE="imagecopyresized"
HREF="function.imagecopyresized.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.imagecopymergegray.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.imagecopyresized.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.imagecopyresampled"
></A
>imagecopyresampled</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN83688"
></A
><P
>    (PHP 4 &#62;= 4.0.6, PHP 5)</P
>imagecopyresampled&nbsp;--&nbsp;Copy and resize part of an image with resampling</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN83691"
></A
><H2
>Descrição</H2
>bool <B
CLASS="methodname"
>imagecopyresampled</B
> ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )<BR
></BR
><P
>&#13;   <B
CLASS="function"
>imagecopyresampled()</B
> copies a rectangular
   portion of one image to another image, smoothly interpolating pixel
   values so that, in particular, reducing the size of an image still
   retains a great deal of clarity.
  </P
><P
>&#13;   If the source and destination coordinates and width and heights
   differ, appropriate stretching or shrinking of the image fragment
   will be performed. The coordinates refer to the upper left
   corner.  This function can be used to copy regions within the
   same image (if <CODE
CLASS="parameter"
>dst_image</CODE
> is the same as
   <CODE
CLASS="parameter"
>src_image</CODE
>) but if the regions overlap the
   results will be unpredictable.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN83731"
></A
><H2
>Parâmetros</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>dst_im</CODE
></DT
><DD
><P
>&#13;       Destination image link resource
      </P
></DD
><DT
><CODE
CLASS="parameter"
>src_im</CODE
></DT
><DD
><P
>&#13;       Source image link resource
      </P
></DD
><DT
><CODE
CLASS="parameter"
>dst_x</CODE
></DT
><DD
><P
>&#13;       x-coordinate of destination point
      </P
></DD
><DT
><CODE
CLASS="parameter"
>dst_y</CODE
></DT
><DD
><P
>&#13;       y-coordinate of destination point
      </P
></DD
><DT
><CODE
CLASS="parameter"
>src_x</CODE
></DT
><DD
><P
>&#13;       x-coordinate of source point
      </P
></DD
><DT
><CODE
CLASS="parameter"
>src_y</CODE
></DT
><DD
><P
>&#13;       y-coordinate of source point
      </P
></DD
><DT
><CODE
CLASS="parameter"
>dst_w</CODE
></DT
><DD
><P
>&#13;       Destination width
      </P
></DD
><DT
><CODE
CLASS="parameter"
>dst_h</CODE
></DT
><DD
><P
>&#13;       Destination height
      </P
></DD
><DT
><CODE
CLASS="parameter"
>src_w</CODE
></DT
><DD
><P
>&#13;       Source width
      </P
></DD
><DT
><CODE
CLASS="parameter"
>src_h</CODE
></DT
><DD
><P
>&#13;       Source height
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN83785"
></A
><H2
>Valores de retornado</H2
><P
>&#13;   Retorna <TT
CLASS="constant"
><B
>TRUE</B
></TT
> em caso de sucesso ou <TT
CLASS="constant"
><B
>FALSE</B
></TT
> em falhas.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN83790"
></A
><H2
>Exemplos</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN83793"
></A
><P
><B
>Exemplo 1. Simple example</B
></P
><P
>&#13;     This example will resample an image to half its original size.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// The file<br /></font><font color="#0000BB">$filename </font><font color="#007700">= </font><font color="#DD0000">'test.jpg'</font><font color="#007700">;<br /></font><font color="#0000BB">$percent </font><font color="#007700">= </font><font color="#0000BB">0.5</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Content type<br /></font><font color="#0000BB">header</font><font color="#007700">(</font><font color="#DD0000">'Content-type: image/jpeg'</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Get new dimensions<br /></font><font color="#007700">list(</font><font color="#0000BB">$width</font><font color="#007700">, </font><font color="#0000BB">$height</font><font color="#007700">) = </font><font color="#0000BB">getimagesize</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">);<br /></font><font color="#0000BB">$new_width </font><font color="#007700">= </font><font color="#0000BB">$width </font><font color="#007700">* </font><font color="#0000BB">$percent</font><font color="#007700">;<br /></font><font color="#0000BB">$new_height </font><font color="#007700">= </font><font color="#0000BB">$height </font><font color="#007700">* </font><font color="#0000BB">$percent</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Resample<br /></font><font color="#0000BB">$image_p </font><font color="#007700">= </font><font color="#0000BB">imagecreatetruecolor</font><font color="#007700">(</font><font color="#0000BB">$new_width</font><font color="#007700">, </font><font color="#0000BB">$new_height</font><font color="#007700">);<br /></font><font color="#0000BB">$image </font><font color="#007700">= </font><font color="#0000BB">imagecreatefromjpeg</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">);<br /></font><font color="#0000BB">imagecopyresampled</font><font color="#007700">(</font><font color="#0000BB">$image_p</font><font color="#007700">, </font><font color="#0000BB">$image</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">$new_width</font><font color="#007700">, </font><font color="#0000BB">$new_height</font><font color="#007700">, </font><font color="#0000BB">$width</font><font color="#007700">, </font><font color="#0000BB">$height</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Output<br /></font><font color="#0000BB">imagejpeg</font><font color="#007700">(</font><font color="#0000BB">$image_p</font><font color="#007700">, </font><font color="#0000BB">null</font><font color="#007700">, </font><font color="#0000BB">100</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>O exemplo acima irá imprimir
 algo similar a:</P
><P
><IMG
SRC="figures/image.imagecopyresampled.jpg"></P
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN83801"
></A
><P
><B
>Exemplo 2. Resampling an image proportionally</B
></P
><P
>&#13;     This example will display an image with the maximum width,
     or height, of 200 pixels.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// The file<br /></font><font color="#0000BB">$filename </font><font color="#007700">= </font><font color="#DD0000">'test.jpg'</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Set a maximum height and width<br /></font><font color="#0000BB">$width </font><font color="#007700">= </font><font color="#0000BB">200</font><font color="#007700">;<br /></font><font color="#0000BB">$height </font><font color="#007700">= </font><font color="#0000BB">200</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Content type<br /></font><font color="#0000BB">header</font><font color="#007700">(</font><font color="#DD0000">'Content-type: image/jpeg'</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Get new dimensions<br /></font><font color="#007700">list(</font><font color="#0000BB">$width_orig</font><font color="#007700">, </font><font color="#0000BB">$height_orig</font><font color="#007700">) = </font><font color="#0000BB">getimagesize</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$ratio_orig </font><font color="#007700">= </font><font color="#0000BB">$width_orig</font><font color="#007700">/</font><font color="#0000BB">$height_orig</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">$width</font><font color="#007700">/</font><font color="#0000BB">$height </font><font color="#007700">&gt; </font><font color="#0000BB">$ratio_orig</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$width </font><font color="#007700">= </font><font color="#0000BB">$height</font><font color="#007700">*</font><font color="#0000BB">$ratio_orig</font><font color="#007700">;<br />} else {<br />&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$height </font><font color="#007700">= </font><font color="#0000BB">$width</font><font color="#007700">/</font><font color="#0000BB">$ratio_orig</font><font color="#007700">;<br />}<br /><br /></font><font color="#FF8000">// Resample<br /></font><font color="#0000BB">$image_p </font><font color="#007700">= </font><font color="#0000BB">imagecreatetruecolor</font><font color="#007700">(</font><font color="#0000BB">$width</font><font color="#007700">, </font><font color="#0000BB">$height</font><font color="#007700">);<br /></font><font color="#0000BB">$image </font><font color="#007700">= </font><font color="#0000BB">imagecreatefromjpeg</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">);<br /></font><font color="#0000BB">imagecopyresampled</font><font color="#007700">(</font><font color="#0000BB">$image_p</font><font color="#007700">, </font><font color="#0000BB">$image</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">$width</font><font color="#007700">, </font><font color="#0000BB">$height</font><font color="#007700">, </font><font color="#0000BB">$width_orig</font><font color="#007700">, </font><font color="#0000BB">$height_orig</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Output<br /></font><font color="#0000BB">imagejpeg</font><font color="#007700">(</font><font color="#0000BB">$image_p</font><font color="#007700">, </font><font color="#0000BB">null</font><font color="#007700">, </font><font color="#0000BB">100</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>O exemplo acima irá imprimir
 algo similar a:</P
><P
><IMG
SRC="figures/image.imagecopyresampled_2.jpg"></P
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN83808"
></A
><H2
>Notas</H2
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
    There is a problem due to palette image limitations (255+1 colors).
    Resampling or filtering an image commonly needs more colors than 255, a
    kind of approximation is used to calculate the new resampled pixel and its
    color.  With a palette image we try to allocate a new color, if that
    failed, we choose the closest (in theory) computed color.  This is
    not always the closest visual color. That may produce a weird result, like
    blank (or visually blank) images.  To skip this problem, please use a
    truecolor image as a destination image, such as one created by
    <A
HREF="function.imagecreatetruecolor.html"
><B
CLASS="function"
>imagecreatetruecolor()</B
></A
>.
   </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN83813"
></A
><H2
>Veja também</H2
><P
>&#13;   <A
HREF="function.imagecopyresized.html"
><B
CLASS="function"
>imagecopyresized()</B
></A
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.imagecopymergegray.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.imagecopyresized.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>imagecopymergegray</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.image.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>imagecopyresized</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>