Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Five-菜鸟级
NodeJS_668036
提交
7fe21fe5
N
NodeJS_668036
项目概览
Five-菜鸟级
/
NodeJS_668036
与 Fork 源项目一致
Fork自
inscode / NodeJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NodeJS_668036
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7fe21fe5
编写于
2月 06, 2025
作者:
Q
qq_41923622
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Thu Feb 6 14:45:00 CST 2025 inscode
上级
cac48b2a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
43 addition
and
20 deletion
+43
-20
src/tiny-image-editor/src/components/Download.tsx
src/tiny-image-editor/src/components/Download.tsx
+5
-1
src/tiny-image-editor/src/components/Upload.tsx
src/tiny-image-editor/src/components/Upload.tsx
+38
-19
未找到文件。
src/tiny-image-editor/src/components/Download.tsx
浏览文件 @
7fe21fe5
...
...
@@ -71,7 +71,7 @@ const useDownload = () => {
annotations
.
push
(
annotation
);
})
// 打印标注信息
console
.
log
(
'
用户标注信息:
'
,
annotations
,
canvas
.
backgroundImage
.
_element
.
currentSrc
);
console
.
log
(
'
用户标注信息:
'
,
annotations
,
canvas
.
backgroundImage
,
canvas
.
backgroundImage
.
_element
.
currentSrc
);
let
currentSrc
=
canvas
.
backgroundImage
.
_element
.
currentSrc
let
currentSrcSplit
=
currentSrc
.
split
(
'
/
'
)
...
...
@@ -108,6 +108,10 @@ const useDownload = () => {
};
data
[
deviceId
+
'
_
'
+
imgkey
]
=
{
annotations
:
annotations
,
imageWidth
:
canvas
.
backgroundImage
.
width
,
imageHeight
:
canvas
.
backgroundImage
.
height
,
originalCanvasWidth
:
canvas
.
getWidth
(),
originalCanvasHeight
:
canvas
.
getHeight
(),
imgUrl
:
currentSrc
,
imgTitle
:
imageTitle
,
}
...
...
src/tiny-image-editor/src/components/Upload.tsx
浏览文件 @
7fe21fe5
...
...
@@ -7,25 +7,35 @@ import {fabric} from 'fabric';
import
ArrowClass
from
'
../helpers/Arrow
'
;
function
annotationsInit
(
annotations
,
canvas
,
historyRef
){
function
annotationsInit
(
imgData
,
canvas
,
historyRef
){
// 获取当前图片和画布尺寸
const
currentImageWidth
=
canvas
.
backgroundImage
.
width
;
const
currentImageHeight
=
canvas
.
backgroundImage
.
height
;
const
currentCanvasWidth
=
canvas
.
getWidth
();
const
currentCanvasHeight
=
canvas
.
getHeight
();
let
imageWidth
=
imgData
.
originalCanvasWidth
||
imgData
.
imgWidth
;
let
imageHeight
=
imgData
.
originalCanvasHeight
||
imgData
.
imgHeight
;
// 计算缩放比例
const
scaleX
=
currentCanvasWidth
/
imageWidth
;
const
scaleY
=
currentCanvasHeight
/
imageHeight
;
console
.
log
(
"
scaleX,scaleY
"
,
scaleX
,
scaleY
,
currentCanvasWidth
,
currentCanvasHeight
,
currentImageWidth
,
currentImageHeight
,
imageWidth
,
imageHeight
,
imgData
)
// 遍历标注信息,重新创建元素并添加到画布上
annotations
.
forEach
((
annotation
)
=>
{
imgData
.
annotations
.
forEach
((
annotation
)
=>
{
let
newObject
;
switch
(
annotation
.
type
)
{
case
'
rect
'
:
newObject
=
new
fabric
.
Rect
({
left
:
annotation
.
left
,
top
:
annotation
.
top
,
left
:
annotation
.
left
*
scaleX
,
top
:
annotation
.
top
*
scaleY
,
originX
:
'
left
'
,
originY
:
'
top
'
,
width
:
annotation
.
width
,
height
:
annotation
.
height
,
width
:
annotation
.
width
*
scaleX
,
height
:
annotation
.
height
*
scaleY
,
angle
:
annotation
.
angle
||
0
,
fill
:
annotation
.
fill
||
'
rgba(255,0,0,0)
'
,
stroke
:
annotation
.
stroke
,
strokeWidth
:
annotation
.
size
,
strokeWidth
:
annotation
.
size
*
Math
.
max
(
scaleX
,
scaleY
)
,
transparentCorners
:
false
,
opacity
:
annotation
.
opacity
||
1
});
...
...
@@ -34,9 +44,9 @@ function annotationsInit(annotations,canvas,historyRef){
case
'
i-text
'
:
case
'
text
'
:
newObject
=
new
fabric
.
IText
(
annotation
.
text
,
{
left
:
annotation
.
left
,
top
:
annotation
.
top
,
width
:
annotation
.
width
,
left
:
annotation
.
left
*
scaleX
,
top
:
annotation
.
top
*
scaleY
,
width
:
annotation
.
width
*
scaleX
,
fontSize
:
annotation
.
fontSize
,
fill
:
annotation
.
fill
,
id
:
Math
.
random
()
*
4
+
'
_
'
+
Date
.
now
(),
...
...
@@ -45,31 +55,40 @@ function annotationsInit(annotations,canvas,historyRef){
break
;
case
'
circle
'
:
newObject
=
new
fabric
.
Circle
({
left
:
annotation
.
left
,
top
:
annotation
.
top
,
radius
:
annotation
.
width
/
2
,
left
:
annotation
.
left
*
scaleX
,
top
:
annotation
.
top
*
scaleY
,
radius
:
(
annotation
.
width
/
2
)
*
Math
.
max
(
scaleX
,
scaleY
)
,
angle
:
annotation
.
angle
||
0
,
fill
:
annotation
.
fill
||
''
,
originX
:
'
left
'
,
originY
:
'
top
'
,
stroke
:
annotation
.
stroke
,
strokeWidth
:
annotation
.
size
,
strokeWidth
:
annotation
.
size
*
Math
.
max
(
scaleX
,
scaleY
)
,
opacity
:
annotation
.
opacity
||
1
});
break
;
case
'
arrow
'
:
newObject
=
new
ArrowClass
(
annotation
.
pointList
||
[
annotation
.
left
,
annotation
.
top
,
annotation
.
left
,
annotation
.
top
],
{
strokeWidth
:
annotation
.
size
,
strokeWidth
:
annotation
.
size
*
Math
.
max
(
scaleX
,
scaleY
)
,
stroke
:
annotation
.
stroke
,
id
:
new
Date
().
valueOf
()
+
'
_
'
+
Math
.
random
()
*
4
,
});
newObject
.
strokeUniform
=
true
;
break
;
case
'
path
'
:
newObject
=
new
fabric
.
Path
(
annotation
.
path
,
{
const
adjustedPath
=
annotation
.
path
.
map
((
segment
)
=>
{
if
(
typeof
segment
[
1
]
===
'
number
'
)
{
segment
[
1
]
*=
scaleX
;
}
if
(
typeof
segment
[
2
]
===
'
number
'
)
{
segment
[
2
]
*=
scaleY
;
}
return
segment
;
});
newObject
=
new
fabric
.
Path
(
adjustedPath
,
{
fill
:
annotation
.
fill
,
stroke
:
annotation
.
stroke
,
strokeWidth
:
annotation
.
size
,
strokeWidth
:
annotation
.
size
*
Math
.
max
(
scaleX
,
scaleY
)
,
opacity
:
annotation
.
opacity
||
1
});
break
;
...
...
@@ -107,7 +126,7 @@ export const useUpload = () => {
setTimeout
(()
=>
{
if
(
imgData
){
annotationsInit
(
imgData
.
annotations
,
canvas
,
historyRef
);
annotationsInit
(
imgData
,
canvas
,
historyRef
);
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录