问题标签 [liipimaginebundle]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
5894 浏览

caching - How to tell cloudfront to not cache 302 responses from S3 redirects, or, how else to workaround this image caching generation issue

I'm using Imagine via the LIIPImagineBundle for Symfony2 to create cached versions of images stored in S3.

Cached images are stored in an S3 web enabled bucket served by CloudFront. However, the default LIIPImagineBundle implementation of S3 is far too slow for me (checking if the file exists on S3 then creating a URL either to the cached file or to the resolve functionality), so I've worked out my own workflow:

  1. Pass client the cloudfront URL where the cached image should exist
  2. Client requests the image via the cloudfront URL, if it does not exist then the S3 bucket has a redirect rule which 302 redirects the user to an imagine webserver path which generates the cached version of the file and saves it to the appropriate location on S3
  3. The webserve 301 redirects the user back to the cloudfront URL where the image is now stored and the client is served the image.

This is working fine as long as I don't use cloudfront. The problem appears to be that cloudfront is caching the 302 redirect response (even though the http spec states that they shouldn't). Thus, if I use cloudfront, the client is sent in an endless redirect loop back and forth from webserver to cloudfront, and every subsequent request to the file still redirects to the webserver even after the file has been generated.

If I use S3 directly instead of cloudfront there are no issues and this solution is solid.

According to Amazon's documentation S3 redirect rules don't allow me to specify custom headers (to set cache-control headers or the like), and I don't believe that CloudFront allows me to control the caching of redirects (if they do it's well hidden). CloudFront's invalidation options are so limited that I don't think they will work (can only invalidate 3 objects at any time)...I could pass an argument back to cloudfront on the first redirect (from the Imagine webserver) to fix the endless redirect (eg image.jpg?1), but subsequent requests to the same object will still 302 to the webserver then 301 back to cloudfront even though it exists. I feel like there should be an elegant solution to this problem but it's eluding me. Any help would be appreciated!!

0 投票
1 回答
201 浏览

php - LiipImagineBundle Error encodage HTML

I use LiipImagineBundle for re-size my image after upload. I have a error when I tried to upload some Jpeg about HTML encodage.

With jpeg form my camera that's work, but not form my phone camera.

What my browser show only js error and return blank page ?

I didn't understand what is that error.

Full message in french :

L'encodage de caractères du document HTML n'a pas été déclaré. Le document sera affiché avec des caractères incorrects pour certaines configurations de navigateur si le document contient des caractères en dehors de la plage US-ASCII. L'encodage de caractères de la page doit être déclaré dans le document ou dans le protocole de transfert.

controller Symfony2

I have found help to create my compress Function here.

I tried to catch some Exception but nothing work.

Someone have a solution ?

Sorry for my English, I am learning it...

0 投票
0 回答
1835 浏览

php - Symfony2 图像处理

我已经研究了几个小时,无法掌握如何在 Symfony2 中进行一些有效的图像处理。Liip Imagine 捆绑包似乎是要走的路,但我似乎无法让它在开发中为我正常工作。

我想要的是:

  • 在上传时创建图像大小,最好基于 %(我宁愿这样做等待图像请求,因为如果它很大,我不希望那个人在缓存时等待)
  • 在图像上创建水印
  • 从图像、尺寸、DI 等中检索元数据。

我看过以下内容:

配置:

尝试的树枝:

编辑!!

因此,我使用以下代码尝试从我粘贴的上述帖子上传时执行此操作:

现在这一行$image = $dataManager->find($filter, $path)抛出以下错误:

image uploads/files/pic_05052015_827_c6d4b.jpg 的 mime 类型必须是 image/xxx got inode/x-empty。

我对这些深层次的图像有点迷茫。

0 投票
1 回答
1220 浏览

php - 使用 liipimaginebundle 在 Twig 中即时生成动态缩略图

我正在尝试在 symfony 中使用 liipImagineBundle 来即时生成缩略图。用作附加到Entry实体的缩略图的图像的 url,我的 twig 文件像这样调用图像:

它似乎不起作用。我尝试调整 liipimagine 配置的 data_root 属性,但没有成功。我似乎无法告诉 liip 我的图像在web/uploads/images. 源 html 最终看起来像这样:

目前,liip 的配置如下:

不知道在这里做什么,有人可以帮助我吗?

0 投票
1 回答
689 浏览

symfony - 托管后 liipImagineBundle 出现问题

在 symfony2 中,我使用 liipImagineBundle 即时生成缩略图。它曾经在我的本地服务器上完美运行,但在托管共享服务器的站点后我遇到了麻烦。我一直遇到与此处此处描述的相同的问题,即源是http://my_domain.com/media/cache/resolve/my_thumb/uploads/images/entry/DSC_04121.jpg而不是http://out-of-the-nest.com/media/cache/my_thumb/uploads/images/entry/DSC_04121.jpg.

感谢这两个问题,我知道问题出在哪里,但提出的解决方案对我没有帮助。我无权访问配置文件或 php.ini。我尝试使用 filezilla 更改缓存的权限,但变化不大。此外,正如symfony2 文档中所述,我尝试在 app.php 和 app_dev.php 中使用umask(0002);and umask(0000);,但无济于事。

我真的不知道在这里做什么,有人可以帮助我吗?

编辑

事实证明,它毕竟可能不是一个许可问题。Symfony 抛出了一个 NotLoadableException: Source image not found in "/home/outoftheoo/app/../web/uploads/images/entry/DSC_04121.jpg"预期的结果,因为 web 文件夹不存在,我将其重命名为 www,因为这是 ovh 所期望的。我确实配置了 liip 以便它会知道(我认为无论如何)

在 config.yml 但似乎还不够

PS:如果碰巧相关,有问题的共享托管服务器由 OVH 提供。

编辑 2

发现了问题。config.yml缺少一个:

0 投票
1 回答
655 浏览

symfony - 在 ezpublish 5 上设置图像质量

是否可以在“image_variations”配置中为 ezpublish 2014.11 上的 png 图像设置质量。

我正在寻找这样的东西:

在 alias 上找到了 ezpublish doc,但它似乎仅限于 jpeg。

我找到jpegoptim了 liip post processor,但 liipimag 似乎没有optipng后处理器。

所以我的猜测是,我必须在此基础上构建自己的后处理器jpegoptim

任何更简单的解决方案?

0 投票
1 回答
325 浏览

php - AppKernel.php 中的要求 symfony 包

我为 symfony2 创建了供应商包

它需要捆绑包(例如我们的 liip/imagine-bundle)。

在 composer.php 我插入必要的行:

但我有错误 -捆绑“LiipImagineBundle”不存在或未启用。也许您忘记将它添加到 AppKernel.php 文件的 registerBundles() 方法中?

我可以将它添加到 AppKernel.php 中,但我认为这不是一个好习惯。

如何在我的供应商捆绑包中使用需求捆绑包?

0 投票
0 回答
99 浏览

php - Liip 想象无法创建拇指 - 大于 2MB

所以,基本上.. 我可以上传大于 2MB 的文件(php.ini 在三个不同的位置更改 - 大声笑..)。

  • PHP: 5.6
  • Symfony Liip Imagine(可能是 GD 驱动程序,不知道如何检查?)
  • memory_limit = 128MB(尝试更改为 512MB)
  • upload_max_filesize = 30M
  • post_max_size = 30M

仍然......如果文件有 2.1M 拇指失败 - 比everythink 工作正常。拇指只是去位置 /resolved/cache/ 这意味着我知道失败;)

任何想法我应该在哪里或什么地方寻找?

0 投票
1 回答
1001 浏览

php - 如何使用 S3 (AWS SDK v3) 缓存 LiipImagineBundle 生成的图像

我正在尝试使用 S3 Cache ResolverLiipImagineBundle将我的缓存缩略图上传到 S3,但我遇到了一些奇怪的问题。

我正在使用 AWS SDK v ^3.2:

我正在使用 Symfony2 并且在我的 中services.yml,我已经配置了Aws\Credentials\Credentials类和Aws\S3\S3Client使用它来创建客户端的类:

一切正常,我可以将文件上传到 S3。

现在,LiipImagineBundle:的配置似乎具有仅适用于 AWS SDK 2 的配置规则,并且使用缓存解析器LiipImagineBundle会导致“误报” 。aws_s3

我已经尝试了至少三种不同的配置。

配置 1:适用于 AWS 开发工具包 2

这会引发异常:

在呈现模板期间抛出异常(“从实例配置文件元数据服务器检索凭据时出错。(cURL 错误 28:连接在 1006 毫秒后超时(参见http://curl.haxx.se/libcurl/c/ libcurl-errors.html ))") 在 src/AppBundle/Resources/views/Store/show.html.twig 第 135 行。

这是由正在搜索凭证但未找到它们的 AWS 开发工具包引发的。

因此,这种方法似乎行不通。

配置 2:使用Aws\Credentials(AWS 开发工具包 3)

传递凭据的方法S3Client是传递Aws\Credentials. 我通过一个服务来做到这一点,这样我就可以在其他服务中重复使用相同的凭据(这在我使用它将文件上传到 S3 时起作用!):

并在config.yml

如您所见,我将Credentials服务传递给LiipImagineBundle但我收到此错误 FROM Aws\ClientResolver

ClientResolver.php 第 296 行中的 InvalidArgumentException:为“凭据”提供的配置值无效。预期 Aws\Credentials\CredentialsInterface|array|bool|callable,但得到字符串“@shq.amazon.s3Credentials” (长度=25)

凭据:(Aws\Credentials\CredentialsInterface|array|bool|callable)

指定用于签署请求的凭据。提供 Aws\Credentials\CredentialsInterface 对象、“key”、“secret”和可选“token”键的关联数组,false以使用 null 凭证,或用于创建凭证或返回 null 的可调用凭证提供程序。有关内置凭证提供程序的列表,请参阅 Aws\Credentials\CredentialProvider。如果未提供凭据,SDK 将尝试从环境中加载它们。

似乎,它没有传递Credentials引用的类@shq.amazon.s3Credentials,而是简单地传递了 string @shq.amazon.s3Credentials,因此ClientResolver正确地报告传递的参数不正确。

因此,此配置也不起作用。

配置 3:将数组传递给S3Client(AWS SDK 3)

实例化 a 的第三种方法S3Client将关联数组传递给硬编码凭据

所以我尝试了这个配置:

但是这次我收到一个错误LiipImagineBundle,似乎不接受数组作为参数:

ScalarNode.php 第 36 行中的 InvalidTypeException:路径“liip_imagine.resolvers.cache_thumb_purchase.aws_s3.client_config.HERE_THERE_IS_DIRECTLY_MY_AWS_KEY”的类型无效。 预期的标量,但得到了数组。

我认为必须更新捆绑包的配置规则,但我不知道该怎么做,因为我对这类事情还没有那么自信。

那么,我怎样才能让LiipImagineBundle/ Symfony 传递类而不是引用Credentials类的字符串呢?是我的错还是有什么东西坏了LiipImagineBundle

(另外,我不明白的奇怪的事情,而不是在路径中使用术语“key”,而是使用“key”的值,即HERE_THERE_IS_DIRECTLY_MY_AWS_KEY. 所以它报告这样的路径liip_imagine.resolvers.cache_thumb_purchase.aws_s3.client_config.HERE_THERE_IS_DIRECTLY_MY_AWS_KEY而不是像这样的路径liip_imagine.resolvers.cache_thumb_purchase.aws_s3.client_config.key-我似乎更正确,不是吗?)。

0 投票
1 回答
1855 浏览

symfony - LiipImagineBundle 想象过滤器不工作

即使我在同一张照片上以完全相同的方式使用它,我对在一个页面上工作而不在其他页面上工作的imagine_filter 有问题。

在我的过滤器工作的第一页中,我有这个 src: http ://myserver.com/media/cache/shooting/photo_preview/75/55cb71cc8ba26-00001.jpg

但是,在过滤器不起作用的页面上,我有这个 src:

有没有人已经有这样的问题?

此外,第一个 src 仅适用于 app.php 而不适用于 app_dev.php。

在我的应用程序中,我使用 Gaufrette 将照片上传到 S3,然后使用 Liip 应用过滤器。缓存在我的服务器上。这是我的配置:

<--- 服务 --->

<--- 高夫雷特 --->

<--- 利普 --->

<--- 树枝 --->