如何在rails中创建图像? (来自 php 中的 imagecreate())
我需要从 imagemagick/rmagick 库创建图像,我应该怎么做? 就像在 php 中一样,它是使用 GD 库完成的,如下所示。
<?php
header ("Content-type: image/png");
$handle = ImageCreate (130, 50) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 255, 0, 0);
ImagePng ($handle);
?>
在输入中,我已经给出了图像颜色、区域标签的图像坐标……有什么想法吗?
I need to create an image from the imagemagick/rmagick library, How should I do that?
as in php it was done like below with GD library.
<?php
header ("Content-type: image/png");
$handle = ImageCreate (130, 50) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 255, 0, 0);
ImagePng ($handle);
?>
In input, I have given image color, image co-ordinates of area tag like that..any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在系统中安装
ImageMagick
并rmagick
gem,然后:确保您已经编译了支持 PNG 的 ImageMagick。
要发送图像,您可以执行下一步操作:
那么您不需要保存图像,除非您想缓存它。
您可以在此处找到有关使用情况的更多信息
You need
ImageMagick
installed in your system andrmagick
gem, then:Make sure, you have ImageMagick compiled with PNG support.
To send your image, you may do next thing:
Then you don't need to save an image unless you want to cache it.
More information about usage you can find here
这是我用来动态创建内联图像的方法:
并且:
它并不漂亮,但目前可以使用。
Here's what I used to create an inline image on the fly:
And:
It's not pretty, but it works for now.
http://www.imagemagick.org/RMagick/doc/usage.html#reading
http://www.imagemagick.org/RMagick/doc/usage.html#reading