Home Backend Development PHP Tutorial php读取中文图片文件读不了,编码有关问题

php读取中文图片文件读不了,编码有关问题

Jun 13, 2016 am 10:26 AM
email image protected quot

php读取中文图片文件读不了,编码问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $image='小图.jpg';$percent=0.05;$im=getimagesize($image);$width=$im[0];$hight=$im[1];switch ($im[2]) {    case 1:        [email&#160;protected]($image);        break;    case 2:        [email&#160;protected]($image);        break;    case 3:        [email&#160;protected]($image);        break;}$logo='1.jpg';$im1=getimagesize($logo);//print_r($im1);switch ($im1[2]) {    case 1:        [email&#160;protected]($logo);        break;    case 2:        [email&#160;protected]($logo);        break;    case 3:        [email&#160;protected]($logo);        break;}imagecopy($im,    $im1,   700,-100,0,0,'440','771');//       底下图     上面图        $te=imagecolorallocate($im,255,255,255);imagettftext($im,12,0,20,20,$te,'../simhei.ttf','新年快乐');$newwidth=$width*$percent;$newheight=$hight*$percent;$new=imagecreatetruecolor($newwidth,$newheight);imagecopyresized($new,$im,0,0,0,0,$newwidth,$newheight,$width,$hight);header("Content-type: image/jpeg");imagejpeg($new);//编译图片//if(imagejpeg($im,'new.jpg')){//    echo "水印成功";//}//imagejpeg($new,'小图.jpg');//imagejpeg($im,'大图.jpg');?>
Copy after login


创建中文名的图片结果是乱码。。php是utf-8的,

------解决方案--------------------
还是推荐用不要用中文命名。
------解决方案--------------------
推荐你使用iconv函数转换文件名称编码为gbk试试
------解决方案--------------------
php本身是不支持中文的,要转一下。
具体步骤如下:
$image=iconv("UTF-8", "gb2312", $image);
第一个参数是输入的字符编码,第二个是你想要转的字符编码,第三个是被转换的字符串。
------解决方案--------------------
将该php文件另存为。注意保存的编码
------解决方案--------------------
最好的办法就是别用中文
------解决方案--------------------
在window上最好都使用utf-8, 并且显性地声明,不管是不是静态页面,不要用中文名
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use email, smtplib, poplib, imaplib modules to send and receive emails in Python How to use email, smtplib, poplib, imaplib modules to send and receive emails in Python May 16, 2023 pm 11:44 PM

The journey of an email is: MUA: MailUserAgent - Mail User Agent. (i.e. email software similar to Outlook) MTA: MailTransferAgent - Mail transfer agent, which is those email service providers, such as NetEase, Sina, etc. MDA: MailDeliveryAgent - Mail delivery agent. A server of the Email service provider sender->MUA->MTA->MTA->if

How to use Bing Image Creator for free How to use Bing Image Creator for free Feb 27, 2024 am 11:04 AM

This article will introduce seven ways to get high-quality output using the free BingImageCreator. BingImageCreator (now known as ImageCreator for Microsoft Designer) is one of the great online artificial intelligence art generators. It generates highly realistic visual effects based on user prompts. The more specific, clear, and creative your prompts are, the better the results will be. BingImageCreator has made significant progress in creating high-quality images. It now uses Dall-E3 training mode, showing a higher level of detail and realism. However, its ability to consistently produce HD results depends on several factors, including fast

How to delete images from Xiaomi phones How to delete images from Xiaomi phones Mar 02, 2024 pm 05:34 PM

How to delete images on Xiaomi mobile phones? You can delete images on Xiaomi mobile phones, but most users don’t know how to delete images. Next is the tutorial on how to delete images on Xiaomi mobile phones brought by the editor. Interested users can come and join us. Let's see! How to delete images on Xiaomi mobile phone 1. First open the [Album] function in Xiaomi mobile phone; 2. Then check the unnecessary pictures and click the [Delete] button in the lower right corner; 3. Then click [Album] at the top to enter the special area , select [Recycle Bin]; 4. Then directly click [Empty Recycle Bin] as shown in the figure below; 5. Finally, directly click [Permanent Delete] to complete.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Imagemagic installation Centos and Image installation tutorial Imagemagic installation Centos and Image installation tutorial Feb 12, 2024 pm 05:27 PM

LINUX is an open source operating system. Its flexibility and customizability make it the first choice of many developers and system administrators. In the LINUX system, image processing is a very important task, and Imagemagick and Image are Two very popular image processing tools, this article will introduce you to how to install Imagemagick and Image in Centos system, and provide detailed installation tutorials. Imagemagic installation Centos tutorial Imagemagick is a powerful image processing toolset, which can perform various image operations under the command line. The following are the steps to install Imagemagick on Centos system: 1

In Java, can we declare a top-level class as protected or private? In Java, can we declare a top-level class as protected or private? Sep 12, 2023 pm 07:21 PM

No, we cannot declare top-level classes as private or protected. It can be public or default (no modifiers). If there are no modifiers, there should be default access. Syntax //Atoplevelclass publicclassTopLevelClassTest{ //Classbody} If a top-level class is declared as private, the compiler will report an error, prompting "The modifier private is not allowed here." This means that top-level classes cannot be private, the same applies to protected access

Java programs display different access levels Java programs display different access levels Aug 19, 2023 pm 10:09 PM

Access modifiers are used to set the feature of visibility of some particular classes, interfaces, variables, methods, constructors, data members, and the setter methods in Java programming language. In Java environment, we have different types of access modifiers. Default - If we declare a function, it will only be visible in a specific package. Private- If we declare a function, it will be available only in a specific class

Tutorial on how to insert attachments into win10 mailbox Tutorial on how to insert attachments into win10 mailbox Jan 07, 2024 pm 12:14 PM

Many users need to send emails for work in their daily lives, and some even need to attach various plug-in materials for communication. So how to insert attachments? Let’s take a look at the detailed tutorial below. How to insert attachments to win10 mailbox: 1. Open the mailbox 2. Click the "New Mail" icon in the upper left corner 3. Click "Insert" in the upper right corner 4. Click "Attachment" in the upper right corner 5. Select the required "Attachment" 6. Complete

See all articles