PHP 处置图片

Jun 13, 2016 pm 12:48 PM
100 200k jpg

PHP 处理图片

有个上传图片的功能
如何每次把上传的图片大小控制在200K以下?
只能更改图片的尺寸吗?
其实图片的像素和尺寸和清晰度等都有什么联系。。


------解决方案--------------------
可以的。尺寸会影响大小。
------解决方案--------------------
控制一下压缩比例,因为有的图片像素太大的话,比例缩略到指定比例也不一定会小于200k,所以要控制你最大上传图片的大小缩略到200k的最佳比例...
------解决方案--------------------
从目前流行的图片采集设备上看,200K 只不过是一张普通邮票
清晰度是指表示已知大小的目标所耗费的像素素,当然是越多越清晰

比如,头发的直径约在70~100μm之间
你用一个像素表示,那么只是一条细线
你用100个像素表示的话,你将能看到发身上的鳞片
------解决方案--------------------
像素和图片尺寸的关系是单元和总体的关系
像素和图片文件尺寸(字节数)的关系我在#2说了
一幅1024x500像素的无损全彩(24bit)图片就是1500k再加文件头,jpg(非jpg2000)就大概是无损的1/6约250k
说“大概”,“约”是因为jpg有多级压缩率,每像素的颜色值也有影响,故字节数不定
同样像素的“万花筒”和纯色图片,均使用24bit采样,两者无损图片格式的字节数一样,但jpg格式后者字节数就小很多
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 Article Tags

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 convert PNG to JPG on Windows 11 How to convert PNG to JPG on Windows 11 May 12, 2023 pm 03:55 PM

How to convert PNG to JPG on Windows 11

Fix: Can't open JPG files in Windows 11 Fix: Can't open JPG files in Windows 11 Apr 17, 2023 pm 12:37 PM

Fix: Can't open JPG files in Windows 11

How many kilobytes is 200k? How many kilobytes is 200k? Feb 01, 2023 pm 03:47 PM

How many kilobytes is 200k?

Let's talk about how to use php to easily convert WebP to JPG. Let's talk about how to use php to easily convert WebP to JPG. Mar 24, 2023 pm 02:57 PM

Let's talk about how to use php to easily convert WebP to JPG.

What format is jpg? What format is jpg? Jun 21, 2023 am 11:36 AM

What format is jpg?

What does jpg mean? What does jpg mean? Nov 28, 2022 am 09:46 AM

What does jpg mean?

How to convert svg to jpg format How to convert svg to jpg format Nov 24, 2023 am 09:50 AM

How to convert svg to jpg format

How to rename the extension of all files within a folder, including subfolders How to rename the extension of all files within a folder, including subfolders Apr 14, 2023 pm 12:22 PM

How to rename the extension of all files within a folder, including subfolders

See all articles