3 Star 2 Fork 0

Gitee 极速下载 / ossimagemaker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/LDreame/OSSImageMaker
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

OSSImageMaker

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

OSSImageMaker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "OSSImageMaker"

OSS阿里云属性比对

OSSImageMaker OSS阿里云 描述 取值范围
contentModel OSSImageResizeContentModelTypeLift, OSSImageResizeContentModelTypeMfit, OSSImageResizeContentModelTypePad, OSSImageResizeContentModelTypeFixed, OSSImageResizeContentModelTypeFill m 指定缩略的模式:lfit:等比缩放,限制在设定在指定w与h的矩形内的最大图片。mfit:等比缩放,延伸出指定w与h的矩形框外的最小图片。fill:固定宽高,将延伸出指定w与h的矩形框外的最小图片进行居中裁剪。pad:固定宽高,缩略填充fixed:固定宽高,强制缩略 [lfit,mfit,fill,pad,fixed],默认为lfit
width w 指定目标缩略图的宽度。 1-4096
height h 指定目标缩略图的高度。 1-4096
limit limit 指定当目标缩略图大于原图时是否处理。值是 1 表示不处理;值是 0 表示处理。 0/1, 默认是 1
equalRatioScale p 倍数百分比。 小于100,即是缩小,大于100即是放大。 1-1000
screenWidthToHeightScale(自定义属性) 宽高比 屏幕宽 根据传入的比例依据屏幕宽计算高度 高度 screenWidthToHeightScale = ScreenWidth * 1.0 / ScreenHeight 宽高比的值
widthToHeightScale(自定义属性) 普通宽高比 根据指定宽和指定比例计算设置高度 比例 = width / height 限制条件 必须 先配置 width的大小 宽高比的值
heightToWidthScale(自定义属性) 普通宽高比 根据指定高和指定比例计算设置宽度 width / height限制条件 必须先 配置 height的大小; 宽高比的值
resultString(自定义属性) 最终结果值, 调用完OSSImageMaker, 需要调用resultString, 取出已经修改过的图片URL 返回一个e.g http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png?x-oss-process=image/resize,w_200,h_400,m_pad,limit_0

Resize(图片缩放使用范例)

单边缩放

  //将图缩略成高度为100,宽度按比例处理。
  //因为OSSImageMaker 内置转换了 2x 和3x 所以图片的质量转换后 2x 高度200px 2x 高度 300px
  NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
  NSString *oss_url = str.maker.resize.width(@100).resultString;
  

强制宽高缩略

//强制缩略宽高 contentModel 为 fiexd
   // frame 宽高 100 则 2x和3x 分别为 200 和 300px
   NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
   NSString *oss_url = str.maker.resize.width(@100).height(@100)

等比缩放, 限定在矩形框内

//将图缩略成宽度为100,高度为100,按长边优先 contentModel 为lift
   // frame 宽高 100 则 2x和3x 分别为 200 和 300px
   NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
   NSString *oss_url = str.maker.resize.width(@100).height(@100).contentModel(@(OSSImageResizeContentModelTypeLfit)).resultString;

等比缩放, 限定在矩形框内 短边优先

//将图缩略成宽度为100,高度为100,短边优先 contentModel 为mfit
    // frame 宽高 100 则 2x和3x 分别为 200 和 300px
    NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
    NSString *oss_url = str.maker.resize.width(@100).height(@100).contentModel(@(OSSImageResizeContentModelTypeMfit)).resultString;

固定宽高,自动裁剪

//将图缩略成宽度为100,高度为100,contentModel 为fill
    // frame 宽高 100 则 2x和3x 分别为 200 和 300px
    NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
    NSString *oss_url = str.maker.resize.width(@100).height(@100).contentModel(@(OSSImageResizeContentModelTypeFill)).resultString;

缩略填充

//将图按短边缩略到100x100, 然后按红色填充 contentModel pad 模式
    // frame 宽高 100 则 2x和3x 分别为 200 和 300px
    NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
    NSString *oss_url = str.maker.resize.width(@100).height(@100).contentModel(@(OSSImageResizeContentModelTypePad)).color(@"ff0000").resultString;

按比例缩略

NSString *str = @"http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png";
    NSString *oss_url = str.maker.resize.equalRatioScale(@10).resultString;

Author

LDreame, lvguifeng_hsd@126.com

License

OSSImageMaker is available under the MIT license. See the LICENSE file for more info.

Copyright (c) 2017 LDreame <lvguifeng_hsd@126.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

OSSImageMaker OSS, 图片处理, 缩放 示例 要运行示例项目,请克隆 repo,然后先从 Example 目录运行 pod install 。 要求 安装 OSSImageMaker 可通过 CocoaPods 获得。 要安装它,只需将以下行添加到您的 Podfile 中: pod "OSSImageMaker" Resize(图片缩放使用范例) 一下示例使用的图片是张图片宽度 1125 高度 375 的 @3x 的png 图片放在 OSS上面 URL: http://jyjf-test.oss-cn-hangzhou.aliyuncs.com/cms/201706/1a63a8cf9a5043999b53df72fdafc124.png 展开 收起
Objective-C 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors/ossimagemaker.git
git@gitee.com:mirrors/ossimagemaker.git
mirrors
ossimagemaker
ossimagemaker
master

搜索帮助