Skip to content

Add a digital watermark to image。给图片加上数字(盲)水印

License

Notifications You must be signed in to change notification settings

d2rivendell/LHWatermark

Repository files navigation

LHWatermark

CocoaPods CocoaPods CocoaPods

LHWatermark可以给你的图片添加上盲水印。具体原理访问博客

演示

shot01 shot02

使用

第一步

支持cocoaPods 在文件 Podfile 中加入以下内容:

pod 'LHWatermark', '~> 0.0.3'

然后在终端中运行以下命令:

pod install

第二步

嵌入水印:

  //初始化
    LHWatermarkProcessor *  processor = [[LHWatermarkProcessor alloc] initWithImage:image config:[LHConfig defaultConfig]];
    __weak typeof(self) weakSelf = self;
    //把文字水印@"你的名字"添加到image中。 异步线程
    [processor addMarkText:@"你的名字"  result:^(UIImage *watermarkImage) {
        // block中返回加了水印的图片 主线程
        __strong typeof(weakSelf) strongSelf = weakSelf;
        strongSelf.topImgView.image = watermarkImage;
    }];

提取水印:

   UIImage *image = [UIImage imageNamed:ImageName];
     __weak typeof(self) weakSelf = self;
    // 分别传入原图像、加了水印的图像 。异步线程
    [LHWatermarkProcessor restoreImageWithOriginImage:image watermarkImage:[UIImage imageWithContentsOfFile:_imagePath] config:[LHConfig defaultConfig] result:^(UIImage *markImage) {
         __strong typeof(weakSelf) strongSelf = weakSelf;
        // block中返回水印的图片 主线程
         strongSelf.bottomImgView.image = watermarkImage;
    }];

License

本项目采用 MIT license 开源,你可以利用采用该协议的代码做任何事情,只需要继续继承 MIT 协议即可。

About

Add a digital watermark to image。给图片加上数字(盲)水印

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published