mirror of
https://github.com/php/doc-es.git
synced 2026-03-23 23:12:09 +01:00
259 lines
7.8 KiB
XML
259 lines
7.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<refentry xml:id="function.imagecopyresized" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>imagecopyresized</refname>
|
|
<refpurpose>Copia y redimensiona una parte de una imagen</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>imagecopyresized</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>imagecopyresized</function> copia una parte rectangular de una imagen
|
|
en otra imagen de destino. <parameter>dst_image</parameter> es la
|
|
imagen de destino, <parameter>src_image</parameter> es la imagen fuente.
|
|
</para>
|
|
<para>
|
|
En otras palabras, <function>imagecopyresized</function> tomará una
|
|
forma rectangular <parameter>src_image</parameter> de un ancho de
|
|
<parameter>src_width</parameter> y una altura <parameter>src_height</parameter>
|
|
en la posición (<parameter>src_x</parameter>,<parameter>src_y</parameter>)
|
|
y la colocará en una zona rectangular <parameter>dst_image</parameter>
|
|
de un ancho de <parameter>dst_width</parameter> y una altura de
|
|
<parameter>dst_height</parameter> en la posición
|
|
(<parameter>dst_x</parameter>,<parameter>dst_y</parameter>).
|
|
</para>
|
|
<para>
|
|
Si las dimensiones de la fuente y el destino no son iguales, se realiza
|
|
un estiramiento adecuado para hacer coincidir
|
|
las dos. Las coordenadas proporcionadas se definen
|
|
en relación con la esquina superior izquierda. Esta función puede ser
|
|
utilizada para copiar regiones dentro
|
|
de una misma imagen (si <parameter>dst_image</parameter> y
|
|
<parameter>src_image</parameter> son idénticas), pero si las
|
|
regiones se superponen, el resultado podría ser
|
|
inconsistente.
|
|
</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: coordenada del punto de destino.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_y</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Y: coordenada del punto de destino.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_x</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
X: coordenada del punto fuente.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>src_y</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Y: coordenada del punto fuente.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_width</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Ancho del destino.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>dst_height</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Altura del destino.
|
|
</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> y <parameter>src_image</parameter>
|
|
ahora esperan instancias de <classname>GdImage</classname>;
|
|
anteriormente, se esperaban <type>resource</type>s.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Redimensionamiento de una imagen</title>
|
|
<para>
|
|
Este ejemplo mostrará la imagen redimensionada a la mitad de su tamaño original.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Archivo y nuevo tamaño
|
|
$filename = 'test.jpg';
|
|
$percent = 0.5;
|
|
|
|
// Tipo de contenido
|
|
header('Content-Type: image/jpeg');
|
|
|
|
// Cálculo de las nuevas dimensiones
|
|
list($width, $height) = getimagesize($filename);
|
|
$newwidth = $width * $percent;
|
|
$newheight = $height * $percent;
|
|
|
|
// Carga
|
|
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
|
$source = imagecreatefromjpeg($filename);
|
|
|
|
// Redimensionamiento
|
|
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
|
|
|
// Mostrar
|
|
imagejpeg($thumb);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<mediaobject>
|
|
<alt>Visualización del ejemplo: imagecopyresized()</alt>
|
|
<imageobject>
|
|
<imagedata fileref="en/reference/image/figures/imagecopyresized.jpg"/>
|
|
</imageobject>
|
|
</mediaobject>
|
|
<para>
|
|
La imagen mostrada tendrá la mitad del tamaño de la imagen original, pero una
|
|
mejor calidad puede obtenerse utilizando la función
|
|
<function>imagecopyresampled</function>.
|
|
</para>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Existe un problema debido a las limitaciones del tamaño de la paleta
|
|
(255 + 1 colores diferentes). Filtrar o reescalar una imagen
|
|
requiere más de 255 colores, entonces se utiliza una aproximación para
|
|
calcular el nuevo número de colores. Con una paleta, si un nuevo
|
|
color no puede ser asignado, se utiliza el color más cercano (en teoría);
|
|
esto no siempre es el más cercano visualmente.
|
|
Esto puede generar problemas extraños, como imágenes blancas.
|
|
Para evitar este problema, convierta a imágenes TrueColor, como las
|
|
generadas por la función <function>imagecreatetruecolor</function>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>imagecopyresampled</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
|
|
-->
|