# JPImageresizerView: one crop view for images, GIFs and local video on iOS

> JPImageresizerView is an Objective-C crop view for iOS that handles still images, animated GIFs and local video in the same interface, with rotation, mirroring, masks, corner radius and grid cropping. It is deliberately laid out with frames rather than Auto Layout, and its README keeps a candid list of what is not finished yet.

**Rogue24/JPImageresizerView** — 一个专门裁剪图片、GIF、视频的轮子😋 简单易用、功能丰富☕️（高自由度的参数设定、支持旋转和镜像翻转、蒙版、压缩等），能满足绝大部分裁剪的需求。

- Repository: https://github.com/Rogue24/JPImageresizerView
- Stars: 981 · Forks: 166
- Language: Objective-C
- License: MIT
- Published: 2026-10-20 · Updated: 2026-10-20 · Language: en
- Canonical page: https://hysenlabs.com/projects/rogue24-jpimageresizerview

## One crop view for still images, GIFs and local video

JPImageresizerView is an Objective-C component for iOS that crops images, GIFs and video. The project's description is a wheel for cropping images, GIFs and video, simple to use and rich in features, with high freedom parameter configuration, rotation and mirror flipping, masks and compression, and it aims to cover the majority of cropping needs.

The feature list is where the real shape of the component appears. The crop area scales itself to fit. Parameters are configurable to a high degree, covering the spacing between the crop area and the view, the crop aspect ratio and whether scaling is adaptive. There are up to eight drag directions on the crop area. Rotation is supported in four directions, and horizontal and vertical mirror flipping are both available. Two border styles are provided, along with circular frame cropping and a customisable corner radius. The blur effect, border colour, background colour and mask opacity are all configurable, and the border image, the mask image and the initial crop area can be supplied by the caller.

The view area and the spacing around the crop area can be changed at runtime, which is what makes orientation changes workable. GIFs can be cropped, with their own background colour, corner radius, border, outline stroke and content padding settings. Local video can be cropped as a whole segment, as a single frame, or as a custom number of seconds, and it can be turned into a GIF. The current crop state can be saved, images support N-grid cropping, and the README states that the component is compatible with Swift and SwiftUI environments, with a Demo to look at.

So this is a single view that a developer drops into an app to handle the three content types a social or commerce app typically has to let a user trim: a photo, an animated image, and a video clip.

The related project in the README, JPCrop, is a high fidelity copy of the freely rotatable crop feature from a popular Chinese social app, and it is the reference to follow if the requirement is free angle rotation rather than ninety degree steps.

## Configuration runs through JPImageresizerConfigure and chainable setters

The entry point is JPImageresizerConfigure, and it decides what you are cropping before the view is shown. The rule is narrow and worth respecting: the croppable element, meaning the image, the GIF or the video, can only be one of the options and it cannot be nil. The four options are image for an image or GIF passed as a UIImage, imageData for the same passed as NSData, videoURL for a local video passed as an NSURL, and videoAsset for a local video passed as an AVURLAsset.

Everything else is optional configuration. The mainAppearance group holds the main outer container configuration, meaning the stroke colour, the blur effect, the background colour and the mask opacity. Then there is borderImage for a custom border image, frameType for the border style, resizeWHScale for the crop aspect ratio, resizeCornerRadius for the crop corner radius, contentInsets for the spacing between the crop area and the view, maskImage for a mask image, and gifSettings for GIF processing options.

The image path shows how the API is meant to be used, with a chainable builder inside the make block.

```objc
JPImageresizerConfigure *configure = [JPImageresizerConfigure defaultConfigureWithImage:image make:^(JPImageresizerConfigure *configure) {
    // 到这里已经有了默认参数值，可以在这里另外设置你想要的参数值（使用了链式编程方式）
    configure
    .jp_maskAlpha(0.5)
    .jp_strokeColor([UIColor yellowColor])
    .jp_frameType(JPClassicFrameType)
    .jp_contentInsets(contentInsets)
    .jp_bgColor([UIColor orangeColor])
    .jp_isClockwiseRotation(YES)
    .jp_animationCurve(JPAnimationCurveEaseOut);
}];
```

The default values are already in place when the block runs, so the block only has to override what it wants. Two properties are set directly after construction rather than through the chain.

```objc
// 如果想要初始化为正方形，可设置 JPImageresizerConfigure 的 resizeWHScale 属性
configure.resizeWHScale = 1; // 默认为0，完全显示
// 另外如果还需要固定比例的话：
configure.isArbitrarily = YES; // 默认为YES
```

A resizeWHScale of 1 starts the crop as a square, while a value of 0, the default, shows the whole image. The isArbitrarily flag controls whether the user can drag to an arbitrary ratio.

## Video from the photo library arrives rotated and has to be fixed first

The video path is the part of this component with a genuine engineering problem behind it, and the README is unusually candid about it.

Videos taken from the system photo library may have had their direction modified, meaning the user rotated or flipped them in the library. The resulting track has a preferredTransform that is not CGAffineTransformIdentity. Images have an imageOrientation property that says what changed, but a transform value alone does not tell you which rotations and flips were applied, and after a rotation plus a flip the numbers differ, so the crop comes out wrong.

The current workaround is to fix the orientation first and crop afterwards. The README offers two orders. The first is to configure with the fix callbacks attached, then correct after entering the page.

```objc
[JPImageresizerTool fixOrientationVideoWithAsset:videoAsset fixErrorBlock:^(NSURL *cacheURL, JPImageresizerErrorReason reason) {
    // 修正视频方向的错误回调
} fixStartBlock:^(AVAssetExportSession *exportSession) {
    // 修正视频方向的开始回调
    // 返回exportSession，可监听进度或取消导出
} fixCompleteBlock:^(NSURL *cacheURL) {
    // 修正视频方向的完成回调
    // cacheURL：修正方向后的视频导出后的最终存放路径，默认该路径为NSTemporaryDirectory文件夹下，保存该路径，裁剪后删除视频。

    // 开始裁剪，进入裁剪界面
    JPImageresizerConfigure *configure = [JPImageresizerConfigure defaultConfigureWithVideoAsset:[AVURLAsset assetWithURL:cacheURL] make:nil fixErrorBlock:nil fixStartBlock:nil fixProgressBlock:nil fixCompleteBlock:nil];
}];
```

The fixStartBlock hands back the AVAssetExportSession, so progress can be observed and the export cancelled. The fixCompleteBlock receives a cache URL, which by default sits in NSTemporaryDirectory and should be deleted after cropping. The second order is to fix the asset first with JPImageresizerTool, then build the configuration from the corrected file, which avoids showing the crop screen while the export runs.

For anyone integrating this, the operational cost is clear: a video crop involves an extra export pass and a temporary file that has to be cleaned up.

## Frame layout instead of Auto Layout, by deliberate choice

The README states the layout decision plainly: because Auto Layout is not convenient for gesture control, the component currently uses frame layout and does not support Auto Layout.

That is a defensible engineering position rather than an omission. A crop view has to convert between the coordinate space of the displayed image, the crop rectangle, the rotated and flipped result and the original pixel dimensions of the asset, and gesture handling works much more directly in a coordinate space you control frame by frame. Constraints that recompute during a rotation gesture can fight the gesture handling.

The trade-off lands on the integrator. A view that lays itself out with frames does not participate in constraint based layouts, so putting it inside a modern iOS screen means either hosting it in a container view whose frame you manage, or subclassing and adjusting layout behaviour in your own code. The README also mentions that the view area and the crop area spacing can be modified dynamically with support for switching between portrait and landscape, which is how the component copes with rotation in the absence of constraints.

There is a second consequence worth noting. Since the component is a view and not a controller, presenting it is the integrator's job. The configuration object describes what to crop and how it should look, and the Demo in the Example directory is the reference for how that is turned into a screen.

The README also notes the component is compatible with Swift and SwiftUI environments, referring to the Demo, so the Objective-C code is intended to be called from Swift code rather than to be a Swift-only API.

## The TODO list is the most useful part of the README

Most component READMEs list what a library can do. This one also lists what it cannot do yet, and that list is more useful for an adoption decision than the feature list.

The outstanding items are a native Swift version of the library, a crop area that does not scale, cropping video without needing the orientation correction first, cropping remote video, persisting a cache of crop history, splitting the video cropping part, which is the AVFoundation module, out into its own component, and matching the free drag rotation and flip angles of the Apple Photos crop feature.

Read together, these describe a project with a clear sense of direction. The native Swift rewrite is the largest item, and it explains why the README points at a Swift and SwiftUI compatible Demo rather than a Swift API. The AVFoundation split matters for anyone who wants image cropping without dragging the video stack along with it. The free angle rotation item is the same feature that the separate JPCrop project already covers, so the ecosystem has a split between the two.

The recent changes section shows the pace of work on the appearance side. The latest version unified the appearance configuration, covering crop border colour, blur effect, background colour and mask opacity. It added a custom crop corner radius, including the option to hide the radius in the crop frame and apply it only in the final cropped result. It added custom appearance configuration for the mask, including the option to ignore the mask while cropping. And it made it possible to set the crop aspect ratio and arbitrary dragging when a mask or a round cut is used. An iOS 26 style glass crop frame was added as an option in the Demo.

One more line in the README is easy to miss and useful in practice: because the screenshot feature hides other controls automatically, the Demo can produce a clean 3D wallpaper image straight from the crop screen.

## Adding the library to an Xcode project and reading the header

The repository ships both distribution paths that iOS developers expect. There is a JPImageresizerView.podspec at the root for CocoaPods, and a Package.swift for Swift Package Manager, with badges for CocoaPods compatible and SwiftPM compatible. The Example directory contains an Xcode project, an xcworkspace, a Podfile and a Podfile.lock, so the sample app is a working reference rather than a description.

The README points at the podspec and the header file as the places to look for the full parameter list. The head file is explicitly named as the place to see more configurable options beyond the ones summarised in the README, which is the practical way to work out what is adjustable before writing the configuration block.

Documentation is bilingual, with a Chinese README at the root, an English one at README_EN.md, and a third-party article on Juejin linked from the header. The description of the component itself is in Chinese, so an English speaking team gets the API surface from the header and the English document, while the more detailed prose about video orientation and the design decisions is primarily in the Chinese README and the Juejin article.

The cover material that demonstrates the effect, the glass effect border demonstration and the GIF processing demonstration, is stored in the JPCover repository rather than in this one, which is a small practical detail if you are working offline and want the visual reference.

A realistic first use is to open the Example project, run the Demo, pick the content type you need to ship, and copy the corresponding configuration block. The four crop content types are demonstrated there, including the video path with its fix callbacks, which is the part with the most moving pieces.

## MIT licence, version 1.14.0 and a steady release cadence

The licence is MIT, stated in the podspec metadata and in the LICENSE file at the root of the repository. For a UI component that is dropped into an app rather than shipped as a service, that is a straightforward grant with a well understood obligation to keep the copyright notice.

The version history gives the maintenance picture. The current version is 1.14.0, released on 2026-03-05, and the README header states the same current version. Before that came 1.13.2 on 2025-06-08 and 1.11.2 on 2024-01-25, the latter described as optimising and adding some image processing features.

The repository is not archived, and the last push was on 2026-10-14, which is more recent than the newest tag. The development picture therefore looks like continuous work on master with releases cut from it every few months, which is the pattern to expect for a single maintainer component with an active user base.

Two structural details round out the picture. The repository is not a pure source tree: it contains _Pods.xcodeproj, which is generated by CocoaPods and usually should not be committed, and the top level also carries docs/ and an Example/ project with its own workspace. A contributor therefore needs to know which of those files are generated before changing them, and an adopter integrating the component should look at the Example workspace rather than the pod project to understand how the pieces fit together.

## Conclusion

JPImageresizerView fits iOS teams that need cropping for still images, animated GIFs and local video in one place and are willing to accept an Objective-C view with frame based layout. It does not fit projects that need remote video cropping, a native Swift API, or Auto Layout integration, all of which the project's own TODO list names as unfinished. Verify first that the platform floor in JPImageresizerView.podspec and Package.swift covers your deployment target, and that the GIF and video paths of the Demo behave with your asset sizes before committing to it in a shipping flow.

## FAQ

### What can JPImageresizerView crop?

It crops still images, animated GIFs and local video. The croppable element is chosen at initialisation and can only be one of image, imageData, videoURL or videoAsset, and it cannot be nil.

### How do I install JPImageresizerView in an iOS project?

The repository ships a JPImageresizerView.podspec for CocoaPods and a Package.swift for Swift Package Manager. The Example directory contains an Xcode project, a workspace, a Podfile and a Podfile.lock that show the integration in practice.

### Why does video cropping need an orientation fix first?

Videos from the photo library can have a rotated or flipped direction, and a preferredTransform value alone does not reveal which changes were applied, so the crop comes out wrong. The README shows fixing the direction with JPImageresizerTool first, then cropping the corrected asset from the exported cache URL.

### Does JPImageresizerView support Auto Layout?

No. The README explains that Auto Layout is not convenient for gesture control, so the component uses frame layout and currently does not support Auto Layout. The view area and the spacing around the crop area can be changed dynamically for orientation switches instead.

### What is still missing from JPImageresizerView?

The README keeps a TODO list covering a native Swift version, a crop area that does not scale, cropping video without an orientation fix, cropping remote video, persistent crop history, separating the AVFoundation video module, and free angle rotation and flipping like the Apple Photos crop.

## Sources

- [Issues](https://github.com/Rogue24/JPImageresizerView/issues)
- [License: MIT](https://github.com/Rogue24/JPImageresizerView/blob/master/LICENSE)
- [README](https://github.com/Rogue24/JPImageresizerView/blob/master/README.md)
- [Releases](https://github.com/Rogue24/JPImageresizerView/releases)
- [Rogue24/JPImageresizerView on GitHub](https://github.com/Rogue24/JPImageresizerView)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/rogue24-jpimageresizerview
