2012-06-25 19 views
1

我一直在努力將PDF轉換爲JPG,爲此我安裝了imagick和GhostScript。我一直在使用exec()在我的php代碼中進行轉換。現在我的問題是,如果輸入pdf的來源是從doc-> pdf的轉換,那麼縮放時圖像質量就會有顆粒感。在另一方面,我需要保持低於500KB的圖像大小,所以我不能使用使用exec的imagick過濾器()

  • 密度超過200

有沒有辦法保存圖像之前添加任何類型的過濾器,使jpg質量得到改善。

這裏是我的示例代碼:

$inputFileName = 'test.pdf'; 
    $outputFileName = 'converted.jpg'; 
    $sourceFile = escapeshellarg($inputFileName); 
    $outputFile = escapeshellarg($outputFileName); 

    $exe = "convert -density 200 -colorspace RGB {$sourceFile } {$outputFile }";   

    $null = "0"; 

    echo exec($exe, $null, $result); 

任何幫助,將不勝感激!

感謝

回答

1

爲什麼不增加密度和降低質量?例如:

$exe = "convert -density 600 -quality 70 -colorspace RGB {$sourceFile } {$outputFile }";