Objective-C 版的 Thumbor 图像服务,允许您使用流畅的 API 以表达式的形式构建 URI。
该项目主要基于 Square Inc. 的 Pollexor 库,它是用于 JAVA 的 Thumbor 客户端。
// Without encryption:
OCThumbor *thumbor = [OCThumbor createWithHost:@"http://example.com/"];
// With encryption:
OCThumbor *thumbor = [OCThumbor createWithHost:@"http://example.com/" key:@"key"];
OCThumborURLBuilder *builder = [thumbor buildImage:@"example.com/image.png"];
builder.resizeSize = ResizeSizeMake(48,48);
[builder toUrl];
// Produces: /unsafe/48x48/example.com/image.png
OCThumborURLBuilder *builder = [thumbor buildImage:@"example.com/image.png"];
builder.cropEdgeInsets = CropEdgeInsetsMake(10,10,90,90);
builder.resizeSize = ResizeSizeMake(40,40);
builder.smart = YES;
[builder toUrl];
// Produces: /unsafe/10x10:90x90/smart/40x40/example.com/image.png
OCThumborURLBuilder *builder = [thumbor buildImage:@"example.com/image.png"];
builder.cropEdgeInsets = CropEdgeInsetsMake(10,10,90,90);
builder.cropVerticalAlign = VerticalAlignBottom;
builder.cropHorizontalAlign = HorizontalAlignRight;
builder.resizeSize = ResizeSizeMake(40,40);
[builder toUrl];
// Produces: /unsafe/5x5:195x195/right/bottom/95x95/example.com/image.png
OCThumborURLBuilder *builder = [thumbor buildImage:@"example.com/background.png"];
builder.resizeSize = ResizeSizeMake(200,100);
builder.filter = @[roundCorner(10),quality(85)];
[builder toUrl];
// Produces: /unsafe/200x100/filters:round_corner(10,255,255,255):quality(85)/example.com/background.png
Copyright 2014 Daniel Heckrath
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.