English 中文(简体)
图像文档规模差异
原标题:Image file size differences between Imagemagick and GD library

我一直在做一些测试,发现图像像像像像像像制作公司图书馆相比,会产生较大的档案图像。

我曾尝试过使用th器方法,并使用图像成像仪法(有不同的过滤器)进行消化,以形成一种1024x680 j的图像,与JPEG压缩,质量为80,每克分辨率为72皮克,还使用脱衣机。 消除不必要元数据的图像方法。 视各种过滤器,图像成像生成的文档规模总是在700KB至800KB之间。 另一方面,GD图书馆制作了面积1024x680的图像,面积仅为41KB。

任何人都可以解释档案规模的差异。 我在照片店打开了2份档案,检查了发现任何差异,但找不到(DPI、彩色、8个借方等),但是仍然无法解释档案规模的差异。

问题回答
$srgbPath = "pathTosrgbColorProfile";
$srgb = file_get_contents($srgbPath);
$image->profileImage( icc , $srgb);
$image->stripImage();
$image->setImageResolution(72,72);
$image->setImageUnits(1);
$image->setInterlaceScheme(Imagick::INTERLACE_JPEG);
$image->setImageCompression(imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(80);
$image->setColorspace(imagick::COLORSPACE_SRGB);

$image->resizeImage($thumb_width,$thumb_nheight,imagick::FILTER_CATROM,1);
$image->writeImage($destination); 

规模缩小了40KB,其产出为711KB,仍然相当大。 我正在测试的Hi-res原始档案是3008x2000(4.2MB)小块。

<><>Edit>:

我认为,该方法(setCompression(>)并不针对图像,而是使用setImageCompression(setImageCompression Quality(),现在该规模已降至100KB。 现在一切好!

The differnce seems rather large; when I did some tests a couple of years ago the file size of IM was about 5x the size of GD. It would be interesting to see your actual code used.

我当时正在工作,但照片重为592×592,档案50.3KB,我知道其大小与你的大小不相同,但质量为100。

You can run this and see what IM says about the output files: convert image -verbose -identify

EDIT:

你们必须做一些错误的事情,我刚刚进行了试验,结果低于——因为某种原因,th的大小与 res的面积相同! 也许会 a。

原始档案尺寸:4700×3178 2.31MB

- 面积=1021×680 186kb

- th

GD尺寸=1024×682 100kb

$original =  IMG_4979_1.CR2 ;

// Convert to jpg as GD will not work with CR2 files
exec("convert $original image.jpg");

$image = "image.jpg";

exec("convert $image -resize 1024x680 output1.jpg");

exec("convert $image -thumbnail 1024x680 -strip output2.jpg");

// Set the path to the image to resize
$input_image =  image.jpg ;
// Get the size of the original image into an array
$size = getimagesize( $input_image );
// Set the new width of the image
$thumb_width = "1024";
// Calculate the height of the new image to keep the aspect ratio
$thumb_height = ( int )(( $thumb_width/$size[0] )*$size[1] );
// Create a new true color image in the memory
$thumbnail = ImageCreateTrueColor( $thumb_width, $thumb_height );
// Create a new image from file 
$src_img = ImageCreateFromJPEG( $input_image );
// Create the resized image
ImageCopyResampled( $thumbnail, $src_img, 0, 0, 0, 0, $thumb_width, $thumb_height, $size[0], $size[1] );
// Save the image as resized.jpg
ImageJPEG( $thumbnail, "output3.jpg" );
// Clear the memory of the tempory image 
ImageDestroy( $thumbnail );




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签