如何将 JPEG 图像旋转 45°并将其保存回 Haskell 中的磁盘?
如何将 JPEG 图像旋转 45° 并将其保存回磁盘?
How do I rotate a JPEG image by 45° and save it back to disk?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何将 JPEG 图像旋转 45° 并将其保存回磁盘?
How do I rotate a JPEG image by 45° and save it back to disk?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
据我所知,Haskell 还没有好的图像处理库。
更好的方法
您可以使用
hsmagick
(绑定到libmagick)来操作图像。请参阅TomMD 的回答作为示例。
简单的方法
但是如果你想从 Haskell 做到这一点,这可以做到这一点(假设 ImageMagick 可用):
用法:
困难的方法
或者你可以选择困难的方法,并实现 旋转算法。要在 Haskell 中读取和写入几乎所有图像格式,您可以使用 Codec.Image.DevIL< /a> 库。如果您这样做,将这段代码放在 Hackage 上真是太好了。
As far as I know, there is no good image manipulation library for Haskell yet.
Better way
You can use
hsmagick
(bindings to libmagick) to manipulate images.See TomMD's answer for an example.
Easy way
But if you want to do it from Haskell, this can do the trick (assuming that ImageMagick is available):
Usage:
Hard way
Or you can choose the hard way, and implement rotation algorithm yourself. To read and write almost all image formats in Haskell, you can use Codec.Image.DevIL library. If you do it, it would be kind of you to put this code on Hackage.
GD 库可以让你做到这一点,但是 Haskell 绑定 ( http://hackage.haskell.org/package /gd )目前不包含适当的函数。人们还可以向维护者提出功能请求,或者简单地修补它并将其发送到上游。 Graphics.GD.Internal 模块(未导出)实际上已经有一个注释掉的绑定到适当的函数( http://hackage.haskell.org/packages/archive/gd/3000.5.0/doc/html/src/Graphics-GD- Internal.html ),所以我想,完成这项工作应该非常简单(而且我确信,这项工作将受到赞赏)。
The GD library lets you do this, but the Haskell bindings ( http://hackage.haskell.org/package/gd ) don't include the appropriate function at the moment. One also could either make a feature request to the maintainer, or simply patch it and send it upstream. The Graphics.GD.Internal module (not exported) in fact already has a commented out binding to the appropriate function ( http://hackage.haskell.org/packages/archive/gd/3000.5.0/doc/html/src/Graphics-GD-Internal.html ), so it should be very simple, I imagine, to finish the job (and I'm sure, the work will be appreciated).
在 Hackage 上四处看看。我知道 Tim 开始致力于 libmagick 的绑定,但这并不足以阻止我放弃当我需要图像处理时,可以为 GIMP 生成 script-fu,但如果你只是做旋转等简单的事情,这对你来说就足够了:
我看到 Cale 也有一个 ImLib 看起来功能更完整:
正如我所说,环顾四周并让我们知道!
Look around on Hackage. I know Tim started working on bindings to libmagick, which wasn't enough to stop me from dropping down to generating script-fu for GIMP when I needed image manipulation, but it's enough for you if you're just doing simple things like rotation:
I see Cale also has an ImLib that appears more feature complete:
As I said, look around and let us know!