rzmn / cropview Goto Github PK
View Code? Open in Web Editor NEWCrop rectangle view like in Notes App
License: MIT License
Crop rectangle view like in Notes App
License: MIT License
Hi,
I did found a way to perform "select all" on the cropView
, but it's working only with images from the library or ones that taken from the camera, but not from image that created from PDF for example.
This is my solution:
guard let frame = image?.size else { return }
cropView.setCorners(newCorners: [.zero,
CGPoint(x: frame.width, y: 0),
CGPoint(x: frame.width, y: frame.height),
CGPoint(x: 0, y: frame.height)])
From some reason, when I'm running this on an image that created from PDF file, it's returns a very small size, I could say it looks like the thumbnail that you can see in the UIDocumentPickerViewController
, but when I'm setting the image as the image of the imageView
I can see it all over the screen and very sharp, it doesn't looks like the imageView
resized it or something.
So in the bottom line - I wanted to ask if there is some built-in way in the library to perform "select all" or if you have any better idea that will work also with PDF converted to image it will be great.
BTW, the code that I'm using to convert the PDF to UIImage is:
func drawPDFfrom(url: URL) -> UIImage? {
guard let document = CGPDFDocument(url as CFURL) else { return nil }
guard let page = document.page(at: 1) else { return nil }
let pageRect = page.getBoxRect(.mediaBox)
let renderer = UIGraphicsImageRenderer(size: pageRect.size)
let img = renderer.image { ctx in
UIColor.white.set()
ctx.fill(pageRect)
ctx.cgContext.translateBy(x: 0.0, y: pageRect.size.height)
ctx.cgContext.scaleBy(x: 1.0, y: -1.0)
ctx.cgContext.drawPDFPage(page)
}
return img
}
Thanks,
Ido.
Hi,
I added a navigation bar and toolbar(on bottom), tried to add via storyboard the CropView, but seems the coordinates and CropView and uiimageView frame are incorrect. Could you please implement a solution to fix this error, please?
Regards,
Rony
lol. First give u a very bigggggg thanks. because it took long tine to found your lib.
I want to ask that question: can i drag from point in a line, that create new corner from this then we can drag it as normally?
Hi there, nice framework by the way!
I was using another framework that use yours for crop, and I found a memory leak with the picture, and it was easy to fix by declare the "imageView" var as weak var in the class SECropView!
public class SECropView: UIView { ... fileprivate weak var imageView : UIImageView?
hope this help!
Hi,
Could you please implement or add a solution to find coordinates from image and update the points on viewDidAppear method?
Regards,
Rony
Could you tag a new version and update the cocoa pods version with the new fixes? I depend on it for my own library.
Hi,
Firstly thank you for this amazing solution.
Could you please provide a method to get cropped image?
Regards,
Rony
Hi, i have just tested with large image size ( about 2000-1000), then i found the large image size, the small circle corner radius, can you give some advices to fix it? Thanks
Hi again,
Could you please specify a moving(dragging) area of points because they can be moved out of margin(screen).
Regards,
Rony
Hi, is there a way to reconfigure crop corners when the image is rotated? Something like below:
@IBAction func rotatePressed(_ sender: Any) {
let degress = CGFloat.pi / 2
self.imagePreview.transform = imagePreview.transform.rotated(by: degress)
let rotatedImage = imagePreview.image!
cropView.setCorners(newCorners: [
CGPoint(x: 0, y: 0),
CGPoint(x: rotatedImage.size.width, y: 0),
CGPoint(x: rotatedImage.size.width, y: rotatedImage.size.height),
CGPoint(x: 0, y: rotatedImage.size.height)
])
}
Rotation work here but the crop area is not centered on the image. TIA.
When layout subviews called, it goes recursive and causes the app to crash.
It seems the problem is in SECropView.swift
public override func layoutSubviews()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.