Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/starkdmi/swiftorientcrop

Working with oriented images in Swift
https://github.com/starkdmi/swiftorientcrop

cgimage ciimage crop-image image-manipulation image-processing swift vimage

Last synced: about 8 hours ago
JSON representation

Working with oriented images in Swift

Awesome Lists containing this project

README

        

# SwiftOrientCrop

Project content:
- Oriented image generator
- Load and orient CGImage and CIImage
- Orient CGRect based on image orientation
- Crop CGImage, CIImage and vImage
- Benchmarks

Code located in [Tests](SwiftOrientCropTests/SwiftOrientCropTests.swift).

## Oriented image generator

Those images looks the same when correctly displayed, but under the hood they pretty different.

| | | |
| --- | --- | --- |
| | | |
| | | |

### Usage
```Swift
try OrientedGenerator.generateFrom(
source: sourceImageFile,
destination: destinationDirectory,
format: .jpeg,
size: CGSize(width: 1280, height: 1280),
quality: 0.75
)
```

## Image Crop Benchmarks

One call equals to loading 8 images, crop them and write image data to
file. Full execution is 10 single calls - 80 images in summary.

| Method | Full Execution Time (seconds) | Average Execution Time per call (seconds) | Average CPU Time (seconds) | Memory Usage (kB) | Memory Peak Physical (MB) | Disk Writes (MB) | CPU Usage (% relative to CGImage) |
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
| CGImage | 38.719 | 6.372 | 5.365 | 101.6 | __11.6__ | 9.0 | 100% |
| CIImage | __14.432__ | __2.352__ | __1.344__ | 62.3 | 15.0 | 10.9 | 29.3% |
| vImage (CG)\* | 31.458 | 5.186 | 5.162 | __55.7__ | __11.7__ | 9.0 | __23.8%__ |
| vImage (CI)\* | 30.431 | 4.933 | 4.445 | - | 15.4 | 11.0 | 28.8% |

\* vImage doesn't have API to load and save image files, so the CGImage and CIImage was used for it.