[开源项目] PaintKit:不依赖 AppKit 的 Swift 光栅绘图引擎,去背景不用模型
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reviewing the linked PaintKit repository and its BACKGROUND_REMOVAL.md and A_GUARD_TUNED_TO_ITS_TEST.md documents. The submission contains no target file, requested edit, or acceptance criteria, so confirm the repository's contribution format and whether the project should be included before making any change.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
GitHub: https://github.com/joshlin2201/itspaint
自荐一个开源 Swift 包。PaintKit 是我的 Mac 画图和标注应用 ItsPaint 里的绘图引擎,作为独立的 SwiftPM library 发布。它没有 UI 层,不依赖 AppKit、SwiftUI 或任何第三方库,只用到 Foundation、CoreGraphics、ImageIO、CoreText 和 UniformTypeIdentifiers。最低支持 macOS 12,应用本身需要 macOS 14。
推荐理由:
- 去背景不用模型。从图片四个角各做一次 flood fill,把它们的并集设为透明。它不是分割,只认得出“页面”,所以适合 logo、产品图、截图和扫描图,对头发没用。分不出背景时会直接说明,原图不动。实现和两个关键决定: https://github.com/joshlin2201/itspaint/blob/main/docs/BACKGROUND_REMOVAL.md
- 像素用预乘 RGBA8 存储,每次编辑都返回改动的矩形,画布只重绘这一块。撤销历史的上限是内存占用,而不是步数。
- 引擎没有 UI,所以大部分改动可以在终端里验证,构建只需要 Command Line Tools,不需要 Xcode。
- 去背景的判断条件曾经连续三个版本是错的,测试却一直通过。复盘: https://github.com/joshlin2201/itspaint/blob/main/docs/A_GUARD_TUNED_TO_ITS_TEST.md
四行代码就能在本地去掉产品图的背景:
import PaintKit
let engine = PaintEngine(canvas: try ImageCodec.decode(contentsOf: input))
guard engine.removeBackground() else { fatalError("no background to remove") }
try ImageCodec.encode(engine.canvas, as: .png).write(to: output)
ItsPaint 本身免费,MIT 协议,也在 Mac App Store 上架。
English:
PaintKit is the drawing engine inside ItsPaint, my Mac paint and markup app, published as its own SwiftPM product. It has no UI layer and no dependencies. It imports Foundation, CoreGraphics, ImageIO, CoreText and UniformTypeIdentifiers and nothing else, and it supports macOS 12, even though the app needs 14.
- Background removal with no model. It floods from all four corners and makes the union transparent. It is not segmentation, it only knows what a page is, so it works on logos, product shots, screenshots and scans and is useless on hair. When it cannot separate the background it says so and leaves the image alone. The walkthrough: https://github.com/joshlin2201/itspaint/blob/main/docs/BACKGROUND_REMOVAL.md
- Pixels are premultiplied RGBA8, and every edit returns the rectangle it changed, so the canvas redraws only that area. Undo history is capped by memory rather than by a step count.
- With no UI, most changes can be checked from a terminal, and it builds with the Command Line Tools alone.
- The guard on background removal was wrong for three releases while its test passed. The write-up: https://github.com/joshlin2201/itspaint/blob/main/docs/A_GUARD_TUNED_TO_ITS_TEST.md
The four lines above remove the background from a product shot, on device.
The app is free, MIT licensed, and also on the Mac App Store.
- Ngôn ngữ chính
- JavaScript
- Star
- 5k
- Fork
- 431
- Merge trung bình
- 2 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SwiftOldDriver/iOS-Weekly
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
SwiftOldDriver/iOS-Weekly#5449 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
SwiftOldDriver/iOS-Weekly#5446 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
SwiftOldDriver/iOS-Weekly#5445 ·
-
WebKit Features for Safari 27.0Có thể đã có người làm @CrazyCoderShi đã nhận 4 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
SwiftOldDriver/iOS-Weekly#5440 · 1 người được giao ·
-
iPhone Duo: First Developer Good-to-KnowsCó thể đã có người làm @ztlyyznf001 đã nhận 18 ngày trước. Đang mở
SwiftOldDriver/iOS-Weekly#5429 · 1 bình luận · 1 người được giao ·
Tất cả issue của SwiftOldDriver/iOS-Weekly
Issue tương tự
-
feature task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
RealDevSquad/website-www#1178 ·
-
add latest sol modelĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
netlify-labs/nax#56 · 2 bình luận · 1 reaction ·
-
accessibility bug revealjs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
quarto-dev/quarto-cli#14961 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
PnX-SI/GeoNature#4435 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
openlayers/openlayers#17648 ·
Maintainer thường phản hồi trong vòng 1 ngày