首页 \ 问答 \ Symfony中的错误Gd库(Error Gd Libraries in Symfony)

Symfony中的错误Gd库(Error Gd Libraries in Symfony)

我想在symfony中使用gd库,但是我有这个错误

警告:imagecreatefromjpeg():gd-jpeg:JPEG库报告不可恢复的错误:

我的控制器中的脚本是

if (extension_loaded('gd') && function_exists('gd_info')) {
            echo "PHP GD library is enabled in your system.";
        }
        else {
            echo "PHP GD library is not enabled on your system.";
        }

        echo phpinfo();

        $filename = $this->get('kernel')->getRootDir() . '/../web/logo/logo.png';
        $percent = 0.5;

// Content type
//        header('Content-Type: image/jpeg');

// Get new sizes
        list($width, $height) = getimagesize($filename);
        $newwidth = $width * $percent;
        $newheight = $height * $percent;

// Load
        $thumb = imagecreatetruecolor($newwidth, $newheight);
        $source = imagecreatefromjpeg($filename);

// Resize
        imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
        imagejpeg($thumb);

        return new Response("foo");

在我的Phpinfo中,我可以看到GD库。

我正在使用Mamp 3.2.1


I Want to use gd Library with symfony but I have this error

Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:

My script in my Controller is

if (extension_loaded('gd') && function_exists('gd_info')) {
            echo "PHP GD library is enabled in your system.";
        }
        else {
            echo "PHP GD library is not enabled on your system.";
        }

        echo phpinfo();

        $filename = $this->get('kernel')->getRootDir() . '/../web/logo/logo.png';
        $percent = 0.5;

// Content type
//        header('Content-Type: image/jpeg');

// Get new sizes
        list($width, $height) = getimagesize($filename);
        $newwidth = $width * $percent;
        $newheight = $height * $percent;

// Load
        $thumb = imagecreatetruecolor($newwidth, $newheight);
        $source = imagecreatefromjpeg($filename);

// Resize
        imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
        imagejpeg($thumb);

        return new Response("foo");

In my Phpinfo I can see GD libraries.

I'm using Mamp 3.2.1


原文:https://stackoverflow.com/questions/33143016
更新时间:2023-09-29 11:09

最满意答案

如果您打开调试模式,您将在响应正文中获得异常消息。 只需在您的设置中设置DEBUG = True ,或者像这样运行应用程序:

from eve import Eve

app = Eve()
app.run(debug=True)

此外,如果你真的想深入挖掘,你可以克隆存储库并从中安装( pip install -e <path to the repo> 。然后你可以直接在源代码中设置自己的断点。


If you switch debug mode on you will get exception message within the body of the response. Just set DEBUG = True in your settings, or run the application like this:

from eve import Eve

app = Eve()
app.run(debug=True)

Furthermore, if you really want to dig in, you could clone the repository and install from it (pip install -e <path to the repo>. Then you can set your own breakpoints directly in the source code.

相关问答

更多
  • 如果您打开调试模式,您将在响应正文中获得异常消息。 只需在您的设置中设置DEBUG = True ,或者像这样运行应用程序: from eve import Eve app = Eve() app.run(debug=True) 此外,如果你真的想深入挖掘,你可以克隆存储库并从中安装( pip install -e 。然后你可以直接在源代码中设置自己的断点。 If you switch debug mode on you will get exception mes ...
  • 你在使用virtualenv吗? 您可能应该允许您将Eve(或其他)环境与其他环境隔离开来,并避免在此过程中发生冲突。 这就是说,安装Eve就像点击pip install eve一样简单(如果你使用的是virtualenv,则来自虚拟环境内部)。 尝试发出pip freeze ,它将列出已安装的软件包。 将列表与Eve依赖项进行比较,并确保它们已全部安装(您可以使用requirements.txt进行比较)。 编辑:您可能也面临特权问题。 尝试使用sudo pip install eve 。 但同样,你应该 ...
  • 好的,我弄清楚了它的工作原理是什么问题。 用于检查凭据的auth数据库与MONGO_DBNAME相同,而不是MONGO_AUTH_DBNAME值。 所以在我的例子中,用户必须存在于数据库中,而不是像我期望的那样存在于 。 但是, MONGO_AUTHDBNAME设置的目的是MONGO_AUTHDBNAME ? OK I figured out what was wrong to make it work. The auth database that is used ...
  • 我们使用Eve 0.8并使用PostMan执行查询。 这是因为PyEve (当前版本0.8)不支持$ centerSphere运算符。 见eve / io / mongo / mongo.py#L94-L102 。 您可以在PyEve的问题跟踪器上提交操作员支持请求。 另外,值得注意的是,只有MongoDB v3.4 +才能使用带有$centerSphere的$geoWithin 。 We are using Eve 0.8 and the query is performed using PostMan. ...
  • 至少在这种情况下,库之间存在不兼容性,不知道为什么。 通过pip升级Eve和Flask( pip install --upgrade flask和pip install --upgrade eve )然后再次运行。 At least in this case it was in incompatibility between the libraries, no idea why. Upgrade Eve and Flask via pip (pip install --upgrade flask and p ...
  • 因为烧瓶不在哪里'image'文件夹,你应该清楚地指明它。 例如,来自配置。 官方文件: send_from_directory 官方的例子: @app.route('/uploads/') def download_file(filename): return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=T ...
  • WSGI容器期望运行可调用/函数,它们不执行“主”条目。 使用run:Eve,你要求uWSGI(在每次请求时)执行“run”模块中的“Eve”功能(这显然是错误的) 移动 app = Eve(auth=globalauth.TokenAuth) 退出__main__检查并告诉uWSGI使用“run”模块中的'app'可调用 module = run:app WSGI containers expect a callable/function to run, they do not execute you ...
  • 您所要做的就是利用Flask的abort方法: from flask import abort def before_returning_item(resource, _id, document): if resource == "switches": if "interfaces" not in document.keys(): # retrieve and store switch config if it hasn't been stored yet ...
  • 您可以通过在配置设置中设置HATEOAS = False来禁用HATEOAS。 这应该会大大减少有效负载,使其更适合您的使用情况。 编辑:您也可以选择通过将回调函数挂接到on_fetched_resource事件来转换响应有效内容。 from eve import Eve def on_fetched_resource(resource, response): del(response['_links']) del(response['_meta']) # would resul ...
  • 我找到了答案。 是的,我确实需要SDK。 Windows编译器需要在Windows机器上“使用Pip从源安装非纯Python包”并包含在Microsoft Build Tools中。 更多信息可以在这里找到: https : //wiki.python.org/moin/WindowsCompilers I found the answer. Yes, I do need the SDK. Windows compilers are required to "Install a non-pure Pytho ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)