简体   繁体   English

如何在Heroku上使用ImageMagick操纵PNG图像

[英]How to manipulate PNG images using ImageMagick on Heroku

I'm using rmagick gem, and I had to install the PNG library from here locally. 我正在使用rmagick gem,并且必须从此处本地安装PNG库

$ convert --version
Version: ImageMagick 6.8.9-1 Q16 x86_64 2014-05-12 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg ltdl lzma png xml zlib

But on Heroku, I don't have this delegate: 但是在Heroku上,我没有这个代表:

~ $ convert --version
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP    

And it's impossible to install it, because Heroku don't let me use sudo . 而且不可能安装它,因为Heroku不允许我使用sudo

Any ideas on how to solve this? 关于如何解决这个问题的任何想法?

Update 17/11: 更新17/11:

I already using the rmagick gem in my app. 我已经在我的应用程序中使用了rmagick gem。 But, I have to manipulate PNG images and ImageMagick requires the png delegate to do this. 但是,我必须操纵PNG图像,ImageMagick要求png委托来执行此操作。

My problem isn't the gem. 我的问题不是宝石。 But the png delegate. 但是png委托。

You can use a Heroku buildpack to install the dependencies. 您可以使用Heroku buildpack安装依赖项。

There's an ImageMagick buildpack available here . 这里有一个ImageMagick buildpack Just follow the instructions will do. 只需按照说明进行即可。 Feel free to search "ImageMagick buildpack" on the web if you're not using Cedar14 stack. 如果您不使用Cedar14堆栈,请在网上随意搜索“ ImageMagick buildpack”。

Update on Nov 17: 11月17日更新:

Interesting, seems like Heroku already has ImageMagick installed(which explains why I don't have this problem when I use Paperclip gem) and it's pretty easy to require Rmagick class as show in this SO question . 有趣的是,似乎Heroku已经安装了ImageMagick(这解释了为什么我在使用Paperclip gem时没有这个问题),并且很容易要求Rmagick类作为此SO问题中的显示。 Explained in here too . 这里也解释。

gem "rmagick", :require => 'RMagick'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM