将jpg保存为png会增加大小 [英] Saving jpg to png increases size

查看:706
本文介绍了将jpg保存为png会增加大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码将任何格式的图像保存到png:

I use the following code to save any format of image to png :

$crawl_outfile = 'webss_' . uniqid() . '.png';
imagepng(imagecreatefromstring(file_get_contents($src)),$crawl_outfile);

并且它将290 KB的大小增加到1.7 MB. 无法理解原因.有什么方法(参数)来获得较小的图像吗?

And it increases the size of 290 KB to 1.7 MB. Cannot understand the reason. Is there any way(parameter) to get smaller image ?

推荐答案

JPEG是一种有损压缩格式(图像中的某些细节丢失了),而PNG没有.因此,PNG文件会更大.

JPEG is a lossy compression format (some detail in the image is lost), where PNG is not. Therefore, the PNG will be larger in file size.

PNG可以有效地压缩某些东西,例如相同颜色的大区域. JPEG更好地压缩照片.

PNG is efficient at compressing some things, like large areas of the same color. JPEG is better at compressing photos.

这篇关于将jpg保存为png会增加大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆