Skip to content

Commit

Permalink
Update image
Browse files Browse the repository at this point in the history
  • Loading branch information
mowangjuanzi committed Jan 23, 2025
1 parent 1e8d71c commit b5e1b16
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 152 deletions.
5 changes: 2 additions & 3 deletions reference/image/functions/imagefilledpolygon.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 8a2141dcc084f72feb4e0ae2feaff3b440e5c59e Maintainer: dallas Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: dallas Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.imagefilledpolygon" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -123,12 +123,11 @@ $blue = imagecolorallocate($image, 0, 0, 255);
imagefilledrectangle($image, 0, 0, 249, 249, $bg);
// 绘制多边形
imagefilledpolygon($image, $values, 6, $blue);
imagefilledpolygon($image, $values, $blue);
// 输出图像
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
]]>
</programlisting>
Expand Down
9 changes: 4 additions & 5 deletions reference/image/functions/imagefilledrectangle.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: dallas Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: dallas Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.imagefilledrectangle" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -103,16 +103,15 @@
<programlisting role="php">
<![CDATA[
<?php
// Create a 55x30 image
// 创建 55x30 图像
$im = imagecreatetruecolor(55, 30);
$white = imagecolorallocate($im, 255, 255, 255);
// Draw a white rectangle
// 画白色矩形
imagefilledrectangle($im, 4, 4, 50, 25, $white);
// Save the image
// 保存图像
imagepng($im, './imagefilledrectangle.png');
imagedestroy($im);
?>
]]>
</programlisting>
Expand Down
13 changes: 6 additions & 7 deletions reference/image/functions/imagefilltoborder.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: dallas Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: dallas Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.imagefilltoborder" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -95,24 +95,23 @@
<programlisting role="php">
<![CDATA[
<?php
// Create the image handle, set the background to white
// 创建图像句柄,并将背景设置为白色
$im = imagecreatetruecolor(100, 100);
imagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 255, 255, 255));
// Draw an ellipse to fill with a black border
// 绘制椭圆,并用黑色边框填充
imageellipse($im, 50, 50, 50, 50, imagecolorallocate($im, 0, 0, 0));
// Set the border and fill colors
// 设置边框和填充颜色
$border = imagecolorallocate($im, 0, 0, 0);
$fill = imagecolorallocate($im, 255, 0, 0);
// Fill the selection
// 填充选区
imagefilltoborder($im, 50, 50, $border, $fill);
// Output and free memory
// 输出
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
]]>
</programlisting>
Expand Down
51 changes: 19 additions & 32 deletions reference/image/functions/imagefilter.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: ccd3e68e1e8a89a099a32207dd31ed26b70f43cd Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.imagefilter" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -38,9 +38,9 @@
</listitem>
<listitem>
<simpara>
<constant>IMG_FILTER_GRAYSCALE</constant>:将图像转换为灰度,
通过使用与 REC.601 亮度 (Y') 计算相同的系数来更改红色、绿色和蓝色分量的加权和。
保留 alpha 分量。对于调色板图像,由于调色板限制,结果可能有所不同。
<constant>IMG_FILTER_GRAYSCALE</constant>:将图像转换为灰度,通过使用与 REC.601
亮度 (Y') 计算相同的系数来更改红色、绿色和蓝色分量的加权和。保留 alpha
分量。对于调色板图像,由于调色板限制,结果可能有所不同。
</simpara>
</listitem>
<listitem>
Expand Down Expand Up @@ -221,8 +221,7 @@
<refsect1 role="errors">
&reftitle.errors;
<simpara>
抛出 <classname>ValueError</classname> 异常,
如果 <parameter>sub</parameter> 或 <parameter>plus</parameter>
抛出 <classname>ValueError</classname> 异常,如果 <parameter>sub</parameter> 或 <parameter>plus</parameter>
会导致 <constant>IMG_FILTER_SCATTER</constant> <parameter>filter</parameter> 的溢出/下溢。
</simpara>
</refsect1>
Expand All @@ -242,8 +241,7 @@
<row>
<entry>8.4.0</entry>
<entry>
现在抛出 <classname>ValueError</classname> 异常,
如果 <parameter>sub</parameter> 或 <parameter>plus</parameter>
现在抛出 <classname>ValueError</classname> 异常,如果 <parameter>sub</parameter> 或 <parameter>plus</parameter>
会导致 <constant>IMG_FILTER_SCATTER</constant> <parameter>filter</parameter> 的溢出/下溢。
</entry>
</row>
Expand Down Expand Up @@ -279,8 +277,6 @@ else
{
echo 'Conversion to grayscale failed.';
}
imagedestroy($im);
?>
]]>
</programlisting>
Expand All @@ -299,7 +295,6 @@ if($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20))
echo 'Image brightness changed.';
imagepng($im, 'sean.png');
imagedestroy($im);
}
else
{
Expand All @@ -318,13 +313,12 @@ else
<?php
$im = imagecreatefrompng('philip.png');
/* R, G, B, so 0, 255, 0 is green */
/* R、G、B, 所以 0, 255, 0 是绿色 */
if($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0))
{
echo 'Image successfully shaded green.';
imagepng($im, 'philip.png');
imagedestroy($im);
}
else
{
Expand All @@ -341,8 +335,8 @@ else
<programlisting role="php">
<![CDATA[
<?php
// Define our negate function so its portable for
// php versions without imagefilter()
// 定义否定函数,以便可以移植到没有
// imagefilter() 的 php 版本
function negate($im)
{
if(function_exists('imagefilter'))
Expand Down Expand Up @@ -372,7 +366,6 @@ if($im && negate($im))
echo 'Image successfully converted to negative colors.';
imagejpeg($im, 'kalle.jpg', 100);
imagedestroy($im);
}
else
{
Expand All @@ -389,30 +382,25 @@ else
<programlisting role="php">
<![CDATA[
<?php
// Load the PHP logo, we need to create two instances
// to show the differences
// 加载 PHP log,需要创建两个实例
// 来显示差异
$logo1 = imagecreatefrompng('./php.png');
$logo2 = imagecreatefrompng('./php.png');
// Create the image instance we want to show the
// differences on
// 创建想要显示差异的图像实例
$output = imagecreatetruecolor(imagesx($logo1) * 2, imagesy($logo1));
// Apply pixelation to each instance, with a block
// size of 3
// 对每个实例应用像素化,块大小为 3
imagefilter($logo1, IMG_FILTER_PIXELATE, 3);
imagefilter($logo2, IMG_FILTER_PIXELATE, 3, true);
// Merge the differences onto the output image
// 合并差异到输出图像上
imagecopy($output, $logo1, 0, 0, 0, 0, imagesx($logo1) - 1, imagesy($logo1) - 1);
imagecopy($output, $logo2, imagesx($logo2), 0, 0, 0, imagesx($logo2) - 1, imagesy($logo2) - 1);
imagedestroy($logo1);
imagedestroy($logo2);
// Output the differences
// 输出差异
header('Content-Type: image/png');
imagepng($output);
imagedestroy($output);
?>
]]>
</programlisting>
Expand All @@ -431,22 +419,21 @@ imagedestroy($output);
<programlisting role="php">
<![CDATA[
<?php
// Load the image
// 加载图像
$logo = imagecreatefrompng('./php.png');
// Apply a very soft scatter effect to the image
// 对图像应用非常柔和的散射效果
imagefilter($logo, IMG_FILTER_SCATTER, 3, 5);
// Output the image with the scatter effect
// 输出带有散射效果的图像
header('Content-Type: image/png');
imagepng($logo);
imagedestroy($logo);
?>
]]>
</programlisting>
&example.outputs.similar;
<mediaobject>
<alt>Output of example : imagefilter() scatter</alt>
<alt>输出示例:imagefilter() 散射</alt>
<imageobject>
<imagedata fileref="en/reference/image/figures/scatter.png"/>
</imageobject>
Expand Down
20 changes: 10 additions & 10 deletions reference/image/functions/imageftbbox.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.imageftbbox" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand All @@ -22,8 +22,9 @@
</para>
<note>
<para>
在 PHP 8.0.0 之前,<function>imageftbbox</function> 是 <function>imagettfbbox</function> 的扩展变体,它还支持 <parameter>options</parameter>。
自 PHP 8.0.0 起,<function>imagettfbbox</function> 是 <function>imageftbbox</function> 的别名。
在 PHP 8.0.0 之前,<function>imageftbbox</function> 是 <function>imagettfbbox</function> 的扩展变体,它还支持
<parameter>options</parameter>。自 PHP 8.0.0 起,<function>imagettfbbox</function> 是
<function>imageftbbox</function> 的别名。
</para>
</note>
</refsect1>
Expand Down Expand Up @@ -150,31 +151,30 @@
<programlisting role="php">
<![CDATA[
<?php
// Create a 300x150 image
// 创建 300x150 图像
$im = imagecreatetruecolor(300, 150);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Set the background to be white
// 将背景设置为白色
imagefilledrectangle($im, 0, 0, 299, 299, $white);
// Path to our font file
// 字体文件的路径
$font = './arial.ttf';
// First we create our bounding box
// 首先创建边界框
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');
// This is our cordinates for X and Y
// 这是 X 和 Y 坐标
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group');
// Output to browser
// 输出到浏览器
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
]]>
</programlisting>
Expand Down
20 changes: 10 additions & 10 deletions reference/image/functions/imagefttext.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 213fbd9440a224f9c1da4942c85124ce0c120c52 Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.imagefttext" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand All @@ -23,8 +23,9 @@
</methodsynopsis>
<note>
<para>
在 PHP 8.0.0 之前,<function>imagefttext</function> 是 <function>imagettftext</function> 的扩展变体,它还支持 <parameter>options</parameter>。
自 PHP 8.0.0 起,<function>imagettftext</function> 是 <function>imagefttext</function> 的别名。
在 PHP 8.0.0 之前,<function>imagefttext</function> 是 <function>imagettftext</function> 的扩展变体,它还支持
<parameter>options</parameter>。自 PHP 8.0.0 起,<function>imagettftext</function> 是
<function>imagefttext</function> 的别名。
</para>
</note>
</refsect1>
Expand Down Expand Up @@ -94,7 +95,7 @@
// 设置 GD 的环境变量
putenv('GDFONTPATH=' . realpath('.'));
// Name the font to be used (note the lack of the .ttf extension)
// 要使用的字体名称(注意没有 .ttf 扩展名)
$font = 'SomeFont';
?>
]]>
Expand Down Expand Up @@ -212,25 +213,24 @@ $font = 'SomeFont';
<programlisting role="php">
<![CDATA[
<?php
// Create a 300x100 image
// 创建 300x100 图像
$im = imagecreatetruecolor(300, 100);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
// Make the background red
// 将背景设为红色
imagefilledrectangle($im, 0, 0, 299, 99, $red);
// Path to our ttf font file
// ttf 字体文件的路径
$font_file = './arial.ttf';
// Draw the text 'PHP Manual' using font size 13
// 使用字体大小 13 绘制文本“PHP Manual
imagefttext($im, 13, 0, 105, 55, $black, $font_file, 'PHP Manual');
// Output image to the browser
// 输出图像到浏览器
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
]]>
</programlisting>
Expand Down
9 changes: 4 additions & 5 deletions reference/image/functions/imagegammacorrect.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: dallas Status: ready -->
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: dallas Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.imagegammacorrect" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -75,15 +75,14 @@
<programlisting role="php">
<![CDATA[
<?php
// Create image instance
// 创建图像实例
$im = imagecreatefromgif('php.gif');
// Correct gamma, out = 1.537
// 校正伽马,输出 = 1.537
imagegammacorrect($im, 1.0, 1.537);
// Save and free image
// 保存
imagegif($im, './php_gamma_corrected.gif');
imagedestroy($im);
?>
]]>
</programlisting>
Expand Down
Loading

0 comments on commit b5e1b16

Please sign in to comment.