2013-08-26 61 views
1

我有以下代碼:使用試想束調整圖像大小模糊圖像

 $imagine = new \Imagine\Gd\Imagine(); 
     $image = $imagine->open($src); 
     $image_size = $image->getSize(); 
     $image_height = $image_size->getHeight(); 
     $image_width = $image_size->getWidth(); 
     $ratio = 1; 



     $resized_image = $image; 

     $ratio = $image_width/$desired_width; 

     $this->resizedHeight = $image_height/$ratio; 
     $this->resizedWidth = $image_width/$ratio; 
      // thumbnailDir doesn t exist 
     if(!is_dir(dirname($des))) 
       mkdir(dirname($des), 0777, true); 

     $resized_image = $image->resize(new Box($this->resizedWidth, $this->resizedHeight)); 


     $options = array(
      'resolution-units' => ImageInterface::RESOLUTION_PIXELSPERINCH, 
      'resolution-x' => 500, 
      'resolution-y' => 500, 
      'flatten' => false 
     ); 

     $resized_image->save($des, $options); 

出於某種原因,調整後的圖像總是有點模糊,你可以在這裏看到調整後的圖像與原始圖像herehere's的調整大小的圖像。爲什麼這是我的想法。任何想法爲什麼?

+0

其值爲'ImageInterface :: RESOLUTION_PIXELSPERINCH'持有? – schoash

回答

0

當你重新調整圖像的大小時,它會變得模糊,你不能做任何事情。
製作原始圖像的副本,用它來顯示。

查找resize的另一個代碼。

0

我有使用Imagemagick的豐富經驗,它是一個非常強大的命令行圖形編輯工具。我認爲他們已經調整了可以保持質量的機會。大多數在線網絡主機提供免費使用。我相信它周圍有PHP包裝器,但我自己學習了這些命令,並沒有打擾包裝。

提供的文檔和樣本非常詳細,如果您需要幫助,論壇非常活躍。

瞧瞧吧:http://imagemagick.com/script/index.php