2012-03-24 71 views
1

您好我正在Facebook應用程序需要檢索用戶顯示圖片並將其與另一個圖像合併,問題是我使用heroku它不提供GD支持對於JPEG圖像,因此我不能解決它的圖像格式是JPEG格式。不支持GD,任何其他方式來轉換JPEG圖像

  • 我需要一些建議來解決我的這個問題。
  • 是否有可能通過在我的項目中包含一些庫並在我的代碼中引用某個庫來支持jpeg。

這是我得到的同時輸入圖像是JPEG:

Warning: imagecreatefromstring(): Data is not in a recognized format in … Warning: imagegif() expects parameter 1 to be resource, boolean given in…

$dpImageGif = 'temp/'. $userId '.gif'; 
     $url = file_get_contents("http://graph.facebook.com/{$userId}/picture?type=large"); 
$dpImage = 'temp/' . $userId ; 
$imageObject = imagecreatefromstring($url); 
//$imageObject = imagecreatefromjpeg($dpImage); 
imagegif($imageObject, $dpImageGif); 

gd_info():

array(11) { 
    ["GD Version"]=> 
    string(27) "bundled (2.0.34 compatible)" 
    ["FreeType Support"]=> 
    bool(false) 
    ["T1Lib Support"]=> 
    bool(false) 
    ["GIF Read Support"]=> 
    bool(true) 
    ["GIF Create Support"]=> 
    bool(true) 
    ["JPEG Support"]=> 
    bool(false) 
    ["PNG Support"]=> 
    bool(true) 
    ["WBMP Support"]=> 
    bool(true) 
    ["XPM Support"]=> 
    bool(false) 
    ["XBM Support"]=> 
    bool(true) 
    ["JIS-mapped Japanese Font Support"]=> 
    bool(false) 
} 
+2

呃什麼樣的PHP構建不會支持JPEG ...?你有沒有試過看到什麼是甚至包含在$ url? – dqhendricks 2012-03-24 21:34:17

+0

可能dublicate:http://stackoverflow.com/questions/8627701/lack-of-heroku-php-gd-setup-for-jpeg-files-causing-issues – 2012-03-24 21:40:24

回答

2

顯然的Heroku並於PHP,支持ImageMagick的這您可以使用GD代替JPEG圖像處理。對現有的應用程序不是很有用,但如果你從頭開始,它不應該成爲一個問題。

+0

你可以編譯你自己的GD擴展,並使用它在heroku上。 – hakre 2012-05-29 16:05:44

+0

此外,Heroku的PHP構建包是開源的,所以我一直在試圖弄清楚如何將GD與ImageJPEG直接添加到構建包。雖然沒有運氣。 – 2012-05-29 23:11:53

0

我編譯了自己的imagick.so作爲解決方法,請參閱我的回覆@stackoverflow here。讓我知道它是否有效(我嘗試過的基本功能)。

相關問題