{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/10709","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10709/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10709/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10709/events","html_url":"https://github.com/phalcon/cphalcon/issues/10709","id":96946765,"number":10709,"title":"Phalcon\\Image\\Adapter\\Gd 无法生成没有扩展名的图片","user":{"login":"gufei","id":4328293,"avatar_url":"https://avatars.githubusercontent.com/u/4328293?v=3","gravatar_id":"","url":"https://api.github.com/users/gufei","html_url":"https://github.com/gufei","followers_url":"https://api.github.com/users/gufei/followers","following_url":"https://api.github.com/users/gufei/following{/other_user}","gists_url":"https://api.github.com/users/gufei/gists{/gist_id}","starred_url":"https://api.github.com/users/gufei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gufei/subscriptions","organizations_url":"https://api.github.com/users/gufei/orgs","repos_url":"https://api.github.com/users/gufei/repos","events_url":"https://api.github.com/users/gufei/events{/privacy}","received_events_url":"https://api.github.com/users/gufei/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-24T02:30:03Z","updated_at":"2015-07-27T15:22:21Z","closed_at":"2015-07-27T15:22:21Z","body":"根据Phalcon\\Image\\Adapter\\Gd第500行_save方法的实现，Phalcon\\Image\\Adapter\\Gd无法保存没有扩展名的图片，会报错Installed GD does not support '' images\r\n\r\n做如下修改\r\n第一种办法\r\n复写Phalcon\\Image\\Adapter\\Gd的_save方法\r\n\r\n```php\r\n<?\r\nnamespace Phalcon\\Image\\Adapter;\r\n\r\nuse Phalcon\\Image\\Adapter;\r\nuse Phalcon\\Image\\AdapterInterface;\r\nuse Phalcon\\Image\\Exception;\r\n\r\nclass WpfGd extends \\Phalcon\\Image\\Adapter\\Gd implements AdapterInterface{\r\n    protected function _save($file, $quality)\r\n\t{\r\n\r\n\t\t$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));\r\n        \r\n        if(! $ext){\r\n            $ext = image_type_to_extension($this->_type, false);\r\n        }\r\n        \r\n        if (strcmp($ext, \"gif\") == 0) {\r\n\t\t\t$this->_type = 1;\r\n\t\t\t$this->_mime = image_type_to_mime_type($this->_type);\r\n\t\t\timagegif($this->_image, $file);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif (strcmp($ext, \"jpg\") == 0 || strcmp($ext, \"jpeg\") == 0) {\r\n\t\t\t$this->_type = 2;\r\n\t\t\t$this->_mime = image_type_to_mime_type($this->_type);\r\n\t\t\timagejpeg($this->_image, $file, $quality);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif (strcmp($ext, \"png\") == 0) {\r\n\t\t\t$this->_type = 3;\r\n\t\t\t$this->_mime = image_type_to_mime_type($this->_type);\r\n\t\t\timagepng($this->_image, $file);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif (strcmp($ext, \"wbmp\") == 0) {\r\n\t\t\t$this->_type = 15;\r\n\t\t\t$this->_mime = image_type_to_mime_type($this->_type);\r\n\t\t\timagewbmp($this->_image, $file);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif (strcmp($ext, \"xbm\") == 0) {\r\n\t\t\t$this->_type = 16;\r\n\t\t\t$this->_mime = image_type_to_mime_type($this->_type);\r\n\t\t\timagexbm($this->_image, $file);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tthrow new Exception(\"Installed GD does not support '\" . $ext . \"' images\");\r\n\t}\r\n}\r\n```\r\n\r\n第二种办法\r\n修改Phalcon\\Image\\Adapter\\Gd文件\r\n在let ext = strtolower(pathinfo(file, PATHINFO_EXTENSION));\r\n后加上\r\nif !ext {\r\n    let ext = image_type_to_extension(this->_type, false);\r\n}"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/125243207","html_url":"https://github.com/phalcon/cphalcon/issues/10709#issuecomment-125243207","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10709","id":125243207,"user":{"login":"andresgutierrez","id":213590,"avatar_url":"https://avatars.githubusercontent.com/u/213590?v=3","gravatar_id":"","url":"https://api.github.com/users/andresgutierrez","html_url":"https://github.com/andresgutierrez","followers_url":"https://api.github.com/users/andresgutierrez/followers","following_url":"https://api.github.com/users/andresgutierrez/following{/other_user}","gists_url":"https://api.github.com/users/andresgutierrez/gists{/gist_id}","starred_url":"https://api.github.com/users/andresgutierrez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andresgutierrez/subscriptions","organizations_url":"https://api.github.com/users/andresgutierrez/orgs","repos_url":"https://api.github.com/users/andresgutierrez/repos","events_url":"https://api.github.com/users/andresgutierrez/events{/privacy}","received_events_url":"https://api.github.com/users/andresgutierrez/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T15:22:21Z","updated_at":"2015-07-27T15:22:21Z","body":"Fixed in the 2.0.x branch"}}