Useful image tools for iOS
- Extract the primary color of the image(Multiple modes)
- Extract the image pixel color
- Contrast image is equal (based on pixel rather than image name)
- QRcode image generation and recognition
- Image compression
UIColor *whiteColor = [UIColor colorWithRed:1.f green:1.f blue:1.f alpha:1.f];
// extract bright colors and avoid results if close to white color
self.colorArr = [self.imageView.image extractColorsWithMode:JYExtractModeOnlyDistinctColors avoidColor:whiteColor];UIColor *color = [self.imageView.image pixelColorAtLocation:point formImageRect:self.imageView.frame];BOOL isEqual = [self.imageViewOne.image isEqualToImage:self.imageViewTwo.image];
if (isEqual) {
//...Do something..
}
else {
//...Do something..
}// Create QRcode image
UIImage *QRcodeImage = [UIImage QRCodeImageFromString:@"Job-Yang" imageSize:500];
// Recognition QRcode in the image
NSString *info = [QRcodeImage identifyQRCode];// Compressed to 500KB
NSData *compressData = [self.originalImage compressImageToByte:500 * 1024];- Add
pod 'JYImageTool'to your Podfile. - Run
pod installorpod update. - Import
"JYImageTool.h".
- Download all the files in the
JYImageToolsubdirectory. - Add the source files to your Xcode project.
- Import
JYImageTool.h.
JYImageTool is released under the MIT license. See LICENSE file for details.
实用的iOS图片工具
- 图片主色提取(包含多种提取模式)
- 图片像素点颜色提取
- 图片相同比较(基于图片像素而非图片名)
- 二维码图片生成与识别
- 图片压缩
UIColor *whiteColor = [UIColor colorWithRed:1.f green:1.f blue:1.f alpha:1.f];
// 提取较附近更亮的主色,并忽略太接近白色的提取结果
self.colorArr = [self.imageView.image extractColorsWithMode:JYExtractModeOnlyDistinctColors avoidColor:whiteColor];UIColor *color = [self.imageView.image pixelColorAtLocation:point formImageRect:self.imageView.frame];BOOL isEqual = [self.imageViewOne.image isEqualToImage:self.imageViewTwo.image];
if (isEqual) {
//...Do something..
}
else {
//...Do something..
}// 创建二维码图片
UIImage *QRcodeImage = [UIImage QRCodeImageFromString:@"Job-Yang" imageSize:500];
// 识别图片中的二维码
NSString *info = [QRcodeImage identifyQRCode];// 压缩到500KB
NSData *compressData = [self.originalImage compressImageToByte:500 * 1024];- 在 Podfile 中添加
pod 'JYImageTool'. - 执行
pod install或pod update. - 导入
"JYImageTool.h".
- 下载 JYImageTool 文件夹内的所有内容。
- 将 JYImageTool 内的源文件添加(拖放)到你的工程。
- 导入
JYImageTool.h。
JYImageTool 使用 MIT 许可证,详情见 LICENSE 文件。