dtgr6303 2015-09-12 23:49
浏览 96
已采纳

使用Go裁剪和创建缩略图

Is there a way for me to crop an image with Go by giving dimensions and offsets?

I'm thinking of something flexible like this php function: http://php.net/manual/en/function.imagecopyresampled.php

I found this: https://github.com/nfnt/resize But that library does not seem to have an offset option.

I need to be able to crop any area of the original image. Not just scaling down, but also a different positioning of the cropped image.

Any suggestions on how I can achieve this?

  • 写回答

2条回答 默认 最新

  • douzhigan1687 2015-09-13 19:32
    关注

    I'll answer my own question so that it can be of help to other newcomers of Go.

    Reading these two articles helped me greatly to understand how to crop images in Go. No need for third libraries. You decide how to crop an image with points and rectangles which is a very neat way of doing it.

    http://blog.golang.org/go-image-package

    http://blog.golang.org/go-imagedraw-package

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同