2013-08-26 62 views
1
我使用Imagick在PHP創建具有屬性 「色度子採樣」 〜4的圖像

:2:2(2x1,1x1,1x1)Imagick setSamplingFactors在PHP

我使用此代碼:

$image = new Imagick('test.jpg'); 

$factors = array("2,1,1"); 

$image->setSamplingFactors($factors); 

$image->writeImage('test2.jpg'); 

$image->destroy(); 

但結果是:

jpeg:sampling-factor: 2x2,1x1,1x1 

要查看圖像的屬性;我使用:

$image = new Imagick(test2.jpg'); 
$identify = $image->identifyImage(TRUE); 
$data = $identify['rawOutput']; 

我想設置:提前

jpeg:sampling-factor: 2x1,1x1,1x1 

感謝您的幫助和時間

回答

0

我找到了一個解決方案使用了shell_exec,

<?php 

$path = "e3.jpg"; 
$path2 = "e3.jpg"; 
$arr = array("-sampling-factor 4:2:2"); 

$properties = ""; 
foreach ($arr as $property) { 
    $properties .= $property." "; 
} 

$cmd = "convert ".$path." ".$properties." ".$path2; 

shell_exec($cmd); 

?> 

希望使用唯一的方法來找到正確的解決方案。