mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 07:22:16 +01:00
140 lines
4.1 KiB
XML
140 lines
4.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 1534707f677267513659e57f530ed5f4cf08f924 Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry xml:id="imagick.setprogressmonitor" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>Imagick::setProgressMonitor</refname>
|
|
<refpurpose>Define una función de retrollamada a ser llamada durante el procesamiento</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>bool</type><methodname>Imagick::setProgressMonitor</methodname>
|
|
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Define una función de retrollamada que será llamada durante el procesamiento de la imagen Imagick.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>callback</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La función de progreso a llamar. Debe retornar true si el procesamiento de la imagen debe continuar, o false si debe ser cancelado. El argumento offset indica la progresión y el argumento span indica la cantidad total de trabajo a realizar.
|
|
</para>
|
|
|
|
<methodsynopsis xmlns="http://docbook.org/ns/docbook">
|
|
<type>bool</type>
|
|
<methodname>
|
|
<replaceable>callback</replaceable>
|
|
</methodname>
|
|
<methodparam>
|
|
<type>mixed</type><parameter>offset</parameter>
|
|
</methodparam>
|
|
<methodparam>
|
|
<type>mixed</type>
|
|
<parameter>span</parameter>
|
|
</methodparam>
|
|
</methodsynopsis>
|
|
|
|
<caution>
|
|
<para>
|
|
Los valores pasados a la función de retrollamada no son consistentes. En particular, el argumento span puede aumentar durante el procesamiento de la imagen. Debido a esto, el cálculo del porcentaje completo de una operación de imagen no es trivial.
|
|
</para>
|
|
</caution>
|
|
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&imagick.return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title> <function>Imagick::setProgressMonitor</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$abortReason = null;
|
|
|
|
try {
|
|
$imagick = new \Imagick(realpath($this->control->getImagePath()));
|
|
$startTime = time();
|
|
|
|
$callback = function ($offset, $span) use ($startTime, &$abortReason) {
|
|
if (((100 * $offset) / $span) > 20) {
|
|
$abortReason = "Processing reached 20%";
|
|
return false;
|
|
}
|
|
|
|
$nowTime = time();
|
|
|
|
if ($nowTime - $startTime > 5) {
|
|
$abortReason = "Image processing took more than 5 seconds";
|
|
return false;
|
|
}
|
|
if (($offset % 5) == 0) {
|
|
echo "Progress: $offset / $span <br/>";
|
|
}
|
|
return true;
|
|
};
|
|
|
|
$imagick->setProgressMonitor($callback);
|
|
|
|
$imagick->waveImage(2, 15);
|
|
|
|
echo "Data len is: ".strlen($imagick->getImageBlob());
|
|
}
|
|
catch(\ImagickException $e) {
|
|
if ($abortReason != null) {
|
|
echo "Image processing was aborted: ".$abortReason."<br/>";
|
|
}
|
|
else {
|
|
echo "ImagickException caught: ".$e->getMessage()." Exception type is ".get_class($e);
|
|
}
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</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
|
|
-->
|