burhanrashid52/PhotoEditor hiện có 4.5k sao trên GitHub, viết chủ yếu bằng Kotlin. A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
or we can also import the :photoeditor module from sample for further customization
Migrations
AndroidX
PhotoEditor v.1.0.0 is a migration to androidX and dropping the support of older support library. There are no API changes. If you find any issue migrating to v.1.0.0 , please follow this Guide. If you still facing the issue than you can always rollback to v.0.4.0. Any fix in PR are Welcome :)
Kotlin
PhotoEditor v.2.0.0 is fully migrated to Kotlin. You can use v.1.5.1 for the Java version. There are no breaking API changes in these two versions.
Setting up the View
First we need to add PhotoEditorView in our xml layout
We can define our drawable or color resource directly using app:photo_src
We can set the image programmatically by getting source from PhotoEditorView which will return a ImageView so that we can load image from resources,file or (Picasso/Glide)
To use the image editing feature we need to build a PhotoEditor which requires a Context and PhotoEditorView which we have to setup in our xml layout
//Use custom font using latest support library
val mTextRobotoTf = ResourcesCompat.getFont(this, R.font.roboto_medium)
//loading font from asset
val mEmojiTypeFace = Typeface.createFromAsset(getAssets(), "emojione-android.ttf")
mPhotoEditor = PhotoEditor.Builder(this, mPhotoEditorView)
.setPinchTextScalable(pinchTextScalable) // set flag to make text scalable when pinch
.setDefaultTextTypeface(mTextRobotoTf)
.setDefaultEmojiTypeface(mEmojiTypeFace)
.build() // build photo editor sdk
We can customize the properties in the PhotoEditor as per our requirement
Property
Usage
setPinchTextScalable()
set false to disable pinch to zoom on text insertion. Default: true.
setClipSourceImage()
set true to clip the drawing brush to the source image. Default: false.
setDefaultTextTypeface()
set default text font to be added on image
setDefaultEmojiTypeface()
set default font specifc to add emojis
That's it we are done with setting up our library
Drawing
We can customize our brush and paint with different set of property. To start drawing on image we need to enable the drawing mode
Type
Method
Enable/Disable
mPhotoEditor.setBrushDrawingMode(true);
Shape (brush, line, oval, rectangle, arrow)
mPhotoEditor.addShape(shape)
Shape size (px)
mPhotoEditor.setBrushSize(brushSize) or through the a ShapeBuilder
Shape opacity (In %)
mPhotoEditor.setOpacity(opacity) or through the a ShapeBuilder
Shape color
mPhotoEditor.setBrushColor(colorCode) or through the a ShapeBuilder
Brush Eraser
mPhotoEditor.brushEraser()
Note: Whenever we set any property of a brush for drawing it will automatically enable the drawing mode
Shapes
We can draw shapes from v.1.5.0. We use ShapeBuilder to define shape and other properties.
val shapeBuilder = ShapeBuilder()
.withShapeOpacity(100)
.withShapeType(ShapeType.Oval)
.withShapeSize(50f)
photoEditor.setShape(mShapeBuilder)
For more details check ShapeBuilder.
Filter Effect
We can apply inbuild filter to the source images using
To place text away from the default centre position, provide a Position:
photoEditor.addText(
text = inputText,
position = Position(80, 160),
colorCodeTextView = colorCode
)
Java callers must provide all parameters explicitly:
mPhotoEditor.addText(inputText, null, new Position(80, 160), null, colorCode);
After insertion, text can still be dragged, rotated, and scaled on the canvas.
In the sample app, the end-user flow is now:
Tap Text.
Tap the image where the label should appear.
Enter the text in the dialog.
Repeat the same flow to add multiple text labels in different positions on the image.
In order to edit the text we need the view, which we will receive in our PhotoEditor callback. This callback will trigger when we Long Press the added text
mPhotoEditor.setOnPhotoEditorListener(new OnPhotoEditorListener() {
@Override
public void onEditTextChangeListener(View rootView, String text, int colorCode) {
}
});
We need to provide a Bitmap to add our Images mPhotoEditor.addImage(bitmap);
Undo and Redo
mPhotoEditor.undo();
mPhotoEditor.redo();
Deleting
For deleting a Text/Emoji/Image we can click on the view to toggle the view highlighter box which will have a close icon. So, by clicking on the icon we can delete the view.
Saving
In v.3.0.0 onward, we can save an image to a file using coroutines:
// Please note that if you call this from a fragment, you should call
// 'viewLifecycleOwner.lifecycleScope.launch' instead.
lifecycleScope.launch {
val result = photoEditor.saveAsFile(filePath)
if (result is SaveFileResult.Success) {
showSnackbar("Image saved!")
} else {
showSnackbar("Couldn't save image")
}
}
You can also save an image to a file from Java. We need to provide a file with callback method when edited image is saved.
mPhotoEditor.saveAsFile(filePath, new PhotoEditor.OnSaveListener() {
@Override
public void onSuccess(@NonNull String imagePath) {
Log.e("PhotoEditor","Image Saved Successfully");
}
@Override
public void onFailure(@NonNull Exception exception) {
Log.e("PhotoEditor","Failed to save Image");
}
});
For more details see Saving
How to contribute?
Check out contribution guidelines 👉CONTRIBUTING.md
Questions?🤔
Hit me on twitter
FAQ
Can I use this library in my app for free?
Yes. It's an open-source library and free to use. If this library has saved your time then showing a little credit will increase my motivation towards making the library better :)
Does it support the CROP feature?
Currently, No. I started to build in branch PE-79. But due to time constraint, I drop the idea. Any PR related to CROP is welcomed :)
Facing issues in applying Filter?
The filter effect is applied using GlSurfaceView and the implementation of this feature causing a lot of issues. Need to think of some other alternative solution. Here is the issue list.
Does is support in other platforms (iOS, Web, Flutter)?
No. Currently, the focus is on making the android library better. We don't have any plans for other Platform.
Other Know Issues
Image Scaling.
Memory Issue in Filter.
Who is using PhotoEditor?
Pixxo
Couple Blog: Long distance
Screenshot Tile (NoRoot)
Note: I will be happy to add your app to the list. Please reach out to me with details. You know how to reach me :)
Credits
This project is inspired from PhotoEditorSDK
Buy a cup of coffee
If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕️
BuyMeACoffee
Lesson Learned from building successful android library PhotoEditor: Droidcon Berlin 2021
Open source Support by JetBrains
MIT License
Copyright (c) 2022 Burhanuddin Rashid
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.
burhanrashid52/PhotoEditor có phải mã nguồn mở không?
Có — burhanrashid52/PhotoEditor phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/burhanrashid52/PhotoEditor.
burhanrashid52/PhotoEditor là gì?
burhanrashid52/PhotoEditor (burhanrashid52/PhotoEditor) là dự án Kotlin trên GitHub. Theo mô tả gốc: A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
burhanrashid52/PhotoEditor so với các dự án Image Tools khác thế nào?
burhanrashid52/PhotoEditor được TopGit xếp vào nhóm Image Tools, với 4.5k sao GitHub và viết bằng Kotlin. Xem trang chủ đề Image Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Cùng nhóm Image Tools còn repo nào?
burhanrashid52/PhotoEditor thuộc nhóm Image Tools trên TopGit, cùng 12 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về burhanrashid52/PhotoEditor ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/burhanrashid52/PhotoEditor là nguồn chính thức.
Vì sao burhanrashid52/PhotoEditor được xếp vào nhóm Image Tools?
TopGit xếp burhanrashid52/PhotoEditor vào nhóm Image Tools dựa trên GitHub topics và mô tả của repo (gắn thẻ: "android", "canvas", "emoji"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
PhotoEditor có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về PhotoEditor.