Is there any lib for working with images? (resize, crop, overlay)

polaris · · 449 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Is there any image processing (resize, crop, overlay) library for GO?</p> <p>If no native lib is available and the only option would be to use one in C with cgo which do you recommend and what do people use?</p> <p>Will it be possible then to just build an .exe file (for win) and binary files for OSX / Linux that people can just use without needing to compile everything themselves?</p> <hr/>**评论:**<br/><br/>TheMerovius: <pre><p><a href="https://godoc.org/image/draw" rel="nofollow">image/draw</a> supports all the operations you mention.</p></pre>daniels0xff: <pre><blockquote> <p>image/draw</p> </blockquote> <p>What about formats? Does it support JPEG, PNG, GIF?</p></pre>TheMerovius: <pre><p><a href="https://godoc.org/image/jpeg" rel="nofollow">JPEG</a>, <a href="https://godoc.org/image/png" rel="nofollow">PNG</a>, <a href="https://godoc.org/image/gif" rel="nofollow">GIF</a>.</p></pre>xtralarge65: <pre><p>What did it say when you looked up the documentation for image/draw?</p></pre>daniels0xff: <pre><p>Hah, yea, you&#39;re right. I&#39;m still just getting started with Go so I&#39;m not always sure where to look for things. </p> <p>Really cool that this is in std lib/packages. </p></pre>saturn_vk: <pre><p>There are quite a few third party libs that build on top of image/draw. Even I have <a href="https://github.com/urandom/drawgl" rel="nofollow">one</a>, though it&#39;s still in development</p></pre>Beldur: <pre><p>I really like <a href="https://github.com/disintegration/gift" rel="nofollow">https://github.com/disintegration/gift</a> and used it in production.</p></pre>daniels0xff: <pre><p>This seems really promising but I don&#39;t see it having any release. </p></pre>Sphax: <pre><p>Just use master.</p></pre>daniels0xff: <pre><p>Is this common practice with Go to not have versions? What if they update their code and in one build my code works and in the next one it doesn&#39;t. </p></pre>Sphax: <pre><p>It is yes. People writing (good) Go packages tend to not break the API. Having written and used Go for 2+ years now, I think there&#39;s one or two packages at most that have broken backwards compatibility for me.</p> <p>With that said, I understand where you&#39;re coming from: even though I don&#39;t use releases per se, I still use fixed version for my production builds. For that, the supported and most used tool for Go is vendoring. By default since Go 1.6, you can put dependencies into a vendor directory at the root of your app and &#34;go build&#34; will automatically search there first. </p> <p>So for example if you import &#34;github.com/example/mypackage&#34; and you have the code in &#34;vendor/github.com/example/mypackage&#34; it will use this code and not the global one in your GOPATH. There are a bunch of tools to manage vendored dependencies but I personally recommend <a href="https://github.com/kardianos/govendor" rel="nofollow">https://github.com/kardianos/govendor</a></p> <p>Anyway, since you said you&#39;re just getting started, I would highly recommend not worrying about any of that right now. Just use master with go get for now. If at some point you want to produce production binaries you can then vendor your dependencies.</p></pre>justinisrael: <pre><p>Shameless plug. I&#39;ve written cgo bindings for OpenImageIO, and maintain bindings for ImageMagick, in case you don&#39;t find enough support in pure Go libs</p> <p><a href="https://github.com/justinfx/openimageigo" rel="nofollow">https://github.com/justinfx/openimageigo</a></p> <p><a href="https://github.com/gographics/imagick" rel="nofollow">https://github.com/gographics/imagick</a></p> <p>I have also successfully produced main binaries that statically link against both of these libs, which made it easy to deploy. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

449 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传