Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
docxtemplater-image-module
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
docxtemplater-image-module
Commits
23c13534
Commit
23c13534
authored
Jan 19, 2015
by
Edgar Hipp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added getImageFromData method
parent
b476346c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
coffee/index.coffee
+7
-5
No files found.
coffee/index.coffee
View file @
23c13534
...
@@ -32,24 +32,26 @@ class ImageModule
...
@@ -32,24 +32,26 @@ class ImageModule
Math
.
round
(
pixel
*
9525
)
Math
.
round
(
pixel
*
9525
)
getSizeFromData
:
(
imgData
)
->
getSizeFromData
:
(
imgData
)
->
[
150
,
150
]
[
150
,
150
]
getImageFromData
:
(
imgData
)
->
fs
.
readFileSync
(
imgData
)
handle
:
(
type
,
data
)
->
handle
:
(
type
,
data
)
->
if
type
==
'replaceTag'
and
data
==
'image'
if
type
==
'replaceTag'
and
data
==
'image'
scopeManager
=
@
manager
.
getInstance
(
'scopeManager'
)
scopeManager
=
@
manager
.
getInstance
(
'scopeManager'
)
templaterState
=
@
manager
.
getInstance
(
'templaterState'
)
templaterState
=
@
manager
.
getInstance
(
'templaterState'
)
tag
=
templaterState
.
textInsideTag
.
substr
(
1
)
tag
=
templaterState
.
textInsideTag
.
substr
(
1
)
img
Name
=
scopeManager
.
getValueFromScope
(
tag
)
img
Data
=
scopeManager
.
getValueFromScope
(
tag
)
if
img
Name
==
'undefined'
then
return
@
replaceBy
(
'<w:t></w:t>'
,
'w:t'
)
if
img
Data
==
'undefined'
then
return
@
replaceBy
(
'<w:t></w:t>'
,
'w:t'
)
try
try
img
Data
=
fs
.
readFileSync
(
imgName
)
img
Buffer
=
@
getImageFromData
(
imgData
)
catch
e
catch
e
return
@
replaceBy
(
'<w:t></w:t>'
,
'w:t'
)
return
@
replaceBy
(
'<w:t></w:t>'
,
'w:t'
)
rId
=
@
imgManager
rId
=
@
imgManager
.
loadImageRels
()
.
loadImageRels
()
.
addImageRels
(
@
getNextImageName
(),
img
Data
)
.
addImageRels
(
@
getNextImageName
(),
img
Buffer
)
sizePixel
=
@
getSizeFromData
(
img
Data
)
sizePixel
=
@
getSizeFromData
(
img
Buffer
)
size
=
[
@
convertPixelsToEmus
(
sizePixel
[
0
]),
@
convertPixelsToEmus
(
sizePixel
[
1
])]
size
=
[
@
convertPixelsToEmus
(
sizePixel
[
0
]),
@
convertPixelsToEmus
(
sizePixel
[
1
])]
if
@
options
.
centered
==
false
if
@
options
.
centered
==
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment