首先,隆重介绍今天的主角:ImageProcessor(http://imageprocessor.org/)。虽然我并没有在实际工作中用到这个库,但是它干净利索的使用方式打动了我,很久以前就存了下来。这个库的开发语言是C#,nuget有下载,提供了一系列可以链式调用的方法来处理图片。关键的一点,它是开源的,代码很清晰,有什么bug和不爽可以自己想怎么改就怎么改。

接下来,需要一提的是,我对图片处理一窍不通。所以,这篇文章是我入门图片处理的记录。当然,矩形圆形直线、RGB这类基础,就不特别提了。

一、图片格式
ImageProcessor内置支持的图片格式,自然也是常见常用的图片格式。包括:
1、bmp:Bitmap,位图,采用位映射存储格式,除了图像深度可选以外,不采用其他任何压缩。
2、gif:Graphics Interchange Format,分为静态GIF和动画GIF,是一种压缩位图格式。
3、jpg(jpeg):Joint Photographic Experts GROUP,可以选择压缩级别。
4、png:Portable Network Graphic Format,其设计目的是试图替代GIF和TIFF文件格式,同时增加一些GIF文件格式所不具备的特性。
5、tif(tiff):Tag Image File Format,是一种灵活的位图格式,主要用来存储包括照片和艺术图在内的图像。

二、图片处理
Alpha 透明度
Changes the opacity of the current image.
Alpha(int percentage) [0,100]

AutoRotate 自转
Performs auto-rotation to ensure that EXIF defined rotation is reflected in the final image.
AutoRotate()

BackgroundColor 背景色
Changes the background color of the current image.
BackgroundColor(Color color)

Brightness 亮度
Changes the brightness of the current image.
Brightness(int percentage) [-100,100]

Constrain 约束
Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio. Produces the same output as the Resize method using ResizeMode.Max
Constrain(Size size)

Contrast 对比度
Changes the contrast of the current image.
Contrast(int percentage) [-100,100]

Crop 裁剪
Crops the current image to the given location and size.
Crop(Rectangle rectangle)
Crop(CropLayer cropLayer)

DetectEdges 边缘检测
Detects the edges in the current image using various one and two dimensional algorithms. If the greyscale parameter is set to false the detected edges will maintain the pixel colors of the originl image.
DetectEdges(IEdgeFilter filter, bool greyscale = true)
IEdgeFilter = KayyaliEdgeFilter、KirschEdgeFilter、Laplacian3X3EdgeFilter、PrewittEdgeFilter...

EntropyCrop 熵裁剪(根据信息量的阈值来裁剪)
Crops an image to the area of greatest entropy. This method works best with images containing large areas of a single color or similar colors around the edges.
EntropyCrop(byte threshold = 128)

Filter 滤镜
Applies a filter to the current image. Use the MatrixFilters class to assign the correct filter
Filter(IMatrixFilter matrixFilter)
IMatrixFilter = BlackWhite、Gotham、Lomograph、Polaroid...

Flip 翻转
Flips the current image either horizontally or vertically.
Flip(bool flipVertically)

Format 格式
Sets the output format of the current image to the matching
Format(ISupportedImageFormat format)
ISupportedImageFormat = BitmapFormat、JpegFormat、GifFormat...

GaussianBlur 高斯模糊
Uses a Gaussian kernel to blur the current image.
GaussianBlur(int size)
GaussianBlur(GaussianLayer gaussianLayer)

GaussianSharpen 高斯锐化
Uses a Gaussian kernel to sharpen the current image.
GaussianSharpen(int size)
GaussianSharpen(GaussianLayer gaussianLayer)

Hue 色调
Alters the hue of the current image changing the overall color.
Hue(int degrees, bool rotate = false)

Mask 遮盖
Applies the given image mask to the current image. Any area containing transparency withing the mask will be removed from the original image. If the mask is larger than the image it will be resized to match the images dimensions.
Mask(Image imageMask, Point? point = null)

Overlay 覆盖
Adds a image overlay to the current image. If the overlay is larger than the image it will be resized to match the images dimensions.
Overlay(ImageLayer imageLayer)

Pixelate 像素化(马赛克)
Pixelates an image with the given size.
Pixelate(int pixelSize, Rectangle? rectangle = null)

Quality 图片质量
Alters the output quality of the current image. This method will only effect the output quality of jpeg images.
Quality(int percentage) [0,100]

ReplaceColor 替换颜色
Replaces a color within the current image.
ReplaceColor(Color target, Color replacement, int fuzziness = 0)

Resize 改变大小
Resizes the current image to the given dimensions. If EXIF metadata is to be preserved the information contained within will also be updated to match.
Resize(Size size)
Resize(ResizeLayer resizeLayer)

Resolution 分辨率
Changes the horizontal and vertical resolution of the image. If EXIF metadata is to be preserved the information contained within will also be updated to match.
Resolution(int w, int h)

Rotate 旋转
Rotates the current image by the given angle without clipping.
Rotate(int degrees)

RoundedCorners 圆整圆角
Adds rounded corners to the current image.
RoundedCorners(int radius)
RoundedCorners(RoundedCornerLayer roundedCornersLayer)

Saturation 饱和度
Changes the saturation of the current image.
Saturation(int percentage)

Tint 色度
Tints the current image with the given color
Tint(Color color)

Vignette 晕影
Adds a vignette image effect to the current image.
Vignette(Color color)

Watermark 水印
Adds a text based watermark to the current image.
Watermark (TextLayer textLayer)

三、尝试
最后,来试一下效果吧。

F#之旅7 - 图片处理入门的更多相关文章

  1. F#之旅8 - 图片处理应用之动画二维码

    首先,先介绍下什么是动画二维码.前些天在网上闲逛,突然看到一个开源项目,发现一种二维码的新玩法.https://github.com/sylnsfar/qrcode/blob/master/READM ...

  2. F# 之旅(上)

    写在前面的话 解答一下在上一篇文章<在Visual Studio中入门F#>中有人的提问, 1. 问:是准备写 F# 系列吗?    答:当然不是,本人也是刚刚学习 F#,只是翻译微软官方 ...

  3. F# 之旅(下)

    写在前面的话 学习 F# 一定要去体会函数式编程的特点,推荐一下阮一峰的日志<函数式编程入门教程>. 在这篇文章中 递归函数 记录和可区分联合类型 模式匹配 可选类型 度量单位 类和接口 ...

  4. F#之旅4 - 小实践之快排

    参考文章:https://swlaschin.gitbooks.io/fsharpforfunandprofit/content/posts/fvsc-quicksort.html F#之旅4 - 小 ...

  5. F#之旅0 - 开端

    F#之旅0 - 开端 UWP的学习告一段落,CozyRSS的UWP版本并没有做.UWP跟wpf开发几乎一模一样,然后又引入了很多针对移动设备的东西,这部分有点像android.没啥太大的意思,不难,估 ...

  6. Selenium WebDriver + Grid2 + RSpec之旅(三) ----入门小例子

    Selenium WebDriver + Grid2 + RSpec之旅(三) ----入门小例子 第一个例子都是比较简单的博客园登录界面,就像学习编程语言时候都是从Hello,World!开始. 1 ...

  7. 一条数据的HBase之旅,简明HBase入门教程-Write全流程

    如果将上篇内容理解为一个冗长的"铺垫",那么,从本文开始,剧情才开始正式展开.本文基于提供的样例数据,介绍了写数据的接口,RowKey定义,数据在客户端的组装,数据路由,打包分发, ...

  8. 一条数据的HBase之旅,简明HBase入门教程-开篇

    常见的HBase新手问题: 什么样的数据适合用HBase来存储? 既然HBase也是一个数据库,能否用它将现有系统中昂贵的Oracle替换掉? 存放于HBase中的数据记录,为何不直接存放于HDFS之 ...

  9. F#之旅6 - 简单AV推荐系统

    上回说到用F#来写爬虫,这只是F#学习第一阶段的第一步.最开始,就对第一阶段做了这样的安排: 1.爬虫爬取AV数据 2.数据处理和挖掘 3.数据可视化(使用ECharts) 4.推荐系统 第一步很快就 ...

随机推荐

  1. Bubble Cup 8 finals B. Bribes (575B)

    题意: 给定一棵n个点和有向边构成的树,其中一些边是合法边,一些边是非法边, 经过非法边需要1的费用,并且经过之后费用翻倍. 给定一个长为m的序列,问从点1开始按顺序移动到序列中对应点的总费用. 1& ...

  2. CentOS7下默认目录安装mono+jexus教程

    一.阅读前须知: 1.本文属于安装完Centos7之后的步骤 2.如果还不了解mono,请点击mono 3.本篇主要内容是使用默认目录安装mono+jexus教程,使用自定义目录请查看使用自定义目录安 ...

  3. 【JSP错误总结】无法访问jsp页面

    运行环境:window 7 64位  JSP服务器 tomcat 7 现象:无法访问JSP页面,如下图所示:

  4. 第一届山东省ACM——Balloons(java)

    Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...

  5. Ubuntu虚拟机中断后重启网络断接错误解决方案

    因为该死的windows自动更新,所以vmplayer经常会被强制关闭. 但重新启动后,会发生不能连接到网络的情况显示: waiting for the network configuration…… ...

  6. C语言位域

    转载自 http://tonybai.com/2013/05/21/talk-about-bitfield-in-c-again/ 再谈C语言位域 五 21 bigwhite技术志 bitfield, ...

  7. C和指针 第十五章 二进制I/O

    二进制I/O 数据写入到文件效率最高的是用二进制形式写入,二进制输出避免了在数值转换为字符串过程中,所涉及的开销和精度损失,但而精致并非人眼所能阅读,所以这个技巧只有当数据被另一个程序按顺序读取才能使 ...

  8. json 使用 (下)

    使用JSON JSON也就是JavaScript Object Notation,是一个描述数据的轻量级语法.JSON的优雅是因为它是JavaScript语言的一个子集.接下来你将看到它为什么如此重要 ...

  9. C#中的LINQ

    从自己的印象笔记里面整理出来,排版欠佳.见谅!   1.LINQ: 语言集成查询(Language Integrated Query) 实例: var q=      from c in catego ...

  10. 使用angular.bootstrap() 完成模块的手动加载

    之前我们看到使用ng-app指令,可以实现模块的自动加载.现在我们看下,angular中如何手动加载模块.需要使用到angular.bootstrap这个函数. <html> <he ...