mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 16:22:37 +02:00
Compare commits
26 Commits
5276f2ba6f
...
3ae2489fa5
Author | SHA1 | Date | |
---|---|---|---|
3ae2489fa5 | |||
7a4cc1cec5 | |||
42c58c733b | |||
aae62f62c3 | |||
0014ba7d86 | |||
9c93b4f1d4 | |||
82aa66c363 | |||
5960c56938 | |||
e79cd346c4 | |||
9cf733b553 | |||
a3851475d2 | |||
418d51662c | |||
88eea07747 | |||
51c04fecb0 | |||
d96e63bc50 | |||
b27a826cd2 | |||
4a43760535 | |||
bc19e5e4ce | |||
7f195a0b79 | |||
a2eeda8479 | |||
17d8161d99 | |||
02583cc715 | |||
8d24f95579 | |||
a7a29d6326 | |||
ed1a312027 | |||
b9115f7f6f |
30
README.md
30
README.md
@ -115,6 +115,8 @@ Options:
|
|||||||
Title : mymanga
|
Title : mymanga
|
||||||
Workers : 8
|
Workers : 8
|
||||||
Profile : KS - Kindle Scribe - 1860x2480
|
Profile : KS - Kindle Scribe - 1860x2480
|
||||||
|
ViewRatio : 1:1.5
|
||||||
|
View : 1653x2480
|
||||||
Quality : 85
|
Quality : 85
|
||||||
Crop : true
|
Crop : true
|
||||||
Brightness : 0
|
Brightness : 0
|
||||||
@ -124,7 +126,6 @@ Options:
|
|||||||
NoBlankPage : false
|
NoBlankPage : false
|
||||||
Manga : true
|
Manga : true
|
||||||
HasCover : true
|
HasCover : true
|
||||||
AddPanelView : false
|
|
||||||
LimitMb : 200 Mb
|
LimitMb : 200 Mb
|
||||||
StripFirstDirectoryFromToc: true
|
StripFirstDirectoryFromToc: true
|
||||||
SortPathMode : path=alphanum, file=alpha
|
SortPathMode : path=alphanum, file=alpha
|
||||||
@ -153,6 +154,8 @@ Options:
|
|||||||
Title : mymanga
|
Title : mymanga
|
||||||
Workers : 8
|
Workers : 8
|
||||||
Profile : KS - Kindle Scribe - 1860x2480
|
Profile : KS - Kindle Scribe - 1860x2480
|
||||||
|
ViewRatio : 1:1.5
|
||||||
|
View : 1653x2480
|
||||||
Quality : 85
|
Quality : 85
|
||||||
Crop : true
|
Crop : true
|
||||||
Brightness : 0
|
Brightness : 0
|
||||||
@ -162,7 +165,6 @@ Options:
|
|||||||
NoBlankPage : false
|
NoBlankPage : false
|
||||||
Manga : true
|
Manga : true
|
||||||
HasCover : true
|
HasCover : true
|
||||||
AddPanelView : false
|
|
||||||
LimitMb : 200 Mb
|
LimitMb : 200 Mb
|
||||||
StripFirstDirectoryFromToc: true
|
StripFirstDirectoryFromToc: true
|
||||||
SortPathMode : path=alphanum, file=alphanum
|
SortPathMode : path=alphanum, file=alphanum
|
||||||
@ -210,7 +212,6 @@ Options:
|
|||||||
NoBlankPage : false
|
NoBlankPage : false
|
||||||
Manga : false
|
Manga : false
|
||||||
HasCover : true
|
HasCover : true
|
||||||
AddPanelView : false
|
|
||||||
LimitMb : nolimit
|
LimitMb : nolimit
|
||||||
StripFirstDirectoryFromToc: false
|
StripFirstDirectoryFromToc: false
|
||||||
SortPathMode : path=alphanum, file=alpha
|
SortPathMode : path=alphanum, file=alpha
|
||||||
@ -224,6 +225,8 @@ Go Comic Converter
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
Profile : KS - Kindle Scribe - 1860x2480
|
Profile : KS - Kindle Scribe - 1860x2480
|
||||||
|
ViewRatio : 1:1.5
|
||||||
|
View : 1653x2480
|
||||||
Quality : 85
|
Quality : 85
|
||||||
Crop : true
|
Crop : true
|
||||||
Brightness : 0
|
Brightness : 0
|
||||||
@ -233,7 +236,6 @@ Options:
|
|||||||
NoBlankPage : false
|
NoBlankPage : false
|
||||||
Manga : true
|
Manga : true
|
||||||
HasCover : true
|
HasCover : true
|
||||||
AddPanelView : false
|
|
||||||
LimitMb : 200 Mb
|
LimitMb : 200 Mb
|
||||||
StripFirstDirectoryFromToc: false
|
StripFirstDirectoryFromToc: false
|
||||||
SortPathMode : path=alphanum, file=alpha
|
SortPathMode : path=alphanum, file=alpha
|
||||||
@ -249,6 +251,8 @@ Go Comic Converter
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
Profile : KS - Kindle Scribe - 1860x2480
|
Profile : KS - Kindle Scribe - 1860x2480
|
||||||
|
ViewRatio : 1:1.5
|
||||||
|
View : 1653x2480
|
||||||
Quality : 85
|
Quality : 85
|
||||||
Crop : true
|
Crop : true
|
||||||
Brightness : 0
|
Brightness : 0
|
||||||
@ -258,7 +262,6 @@ Options:
|
|||||||
NoBlankPage : false
|
NoBlankPage : false
|
||||||
Manga : false
|
Manga : false
|
||||||
HasCover : true
|
HasCover : true
|
||||||
AddPanelView : false
|
|
||||||
LimitMb : 200 Mb
|
LimitMb : 200 Mb
|
||||||
StripFirstDirectoryFromToc: false
|
StripFirstDirectoryFromToc: false
|
||||||
SortPathMode : path=alphanum, file=alpha
|
SortPathMode : path=alphanum, file=alpha
|
||||||
@ -284,7 +287,6 @@ Options:
|
|||||||
NoBlankPage : false
|
NoBlankPage : false
|
||||||
Manga : false
|
Manga : false
|
||||||
HasCover : true
|
HasCover : true
|
||||||
AddPanelView : false
|
|
||||||
LimitMb : nolimit
|
LimitMb : nolimit
|
||||||
|
|
||||||
Reset default to ~/.go-comic-converter.yaml
|
Reset default to ~/.go-comic-converter.yaml
|
||||||
@ -306,12 +308,6 @@ Output:
|
|||||||
Author of the epub
|
Author of the epub
|
||||||
-title string
|
-title string
|
||||||
Title of the epub
|
Title of the epub
|
||||||
-workers int (default CPU)
|
|
||||||
Number of workers
|
|
||||||
-dry
|
|
||||||
Dry run to show all options
|
|
||||||
-dry-verbose
|
|
||||||
Display also sorted files after the TOC
|
|
||||||
|
|
||||||
Config:
|
Config:
|
||||||
-profile string
|
-profile string
|
||||||
@ -360,8 +356,6 @@ Config:
|
|||||||
Manga mode (right to left)
|
Manga mode (right to left)
|
||||||
-hascover (default true)
|
-hascover (default true)
|
||||||
Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.
|
Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.
|
||||||
-addpanelview
|
|
||||||
Add an embeded panel view. On kindle you may not need this option as it is handled by the kindle.
|
|
||||||
-limitmb int
|
-limitmb int
|
||||||
Limit size of the ePub: Default nolimit (0), Minimum 20
|
Limit size of the ePub: Default nolimit (0), Minimum 20
|
||||||
-strip
|
-strip
|
||||||
@ -381,6 +375,14 @@ Default config:
|
|||||||
Reset your parameters to default
|
Reset your parameters to default
|
||||||
|
|
||||||
Other:
|
Other:
|
||||||
|
-workers int (default CPU)
|
||||||
|
Number of workers
|
||||||
|
-dry
|
||||||
|
Dry run to show all options
|
||||||
|
-dry-verbose
|
||||||
|
Display also sorted files after the TOC
|
||||||
|
-quiet
|
||||||
|
Disable progress bar
|
||||||
-version
|
-version
|
||||||
Show current and available version
|
Show current and available version
|
||||||
-help
|
-help
|
||||||
|
3
go.mod
3
go.mod
@ -3,8 +3,10 @@ module github.com/celogeek/go-comic-converter/v2
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/beevik/etree v1.1.0
|
||||||
github.com/disintegration/gift v1.2.1
|
github.com/disintegration/gift v1.2.1
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible
|
github.com/gofrs/uuid v4.4.0+incompatible
|
||||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||||
github.com/nwaples/rardecode v1.1.3
|
github.com/nwaples/rardecode v1.1.3
|
||||||
github.com/raff/pdfreader v0.0.0-20220308062436-033e8ac577f0
|
github.com/raff/pdfreader v0.0.0-20220308062436-033e8ac577f0
|
||||||
github.com/schollz/progressbar/v3 v3.13.1
|
github.com/schollz/progressbar/v3 v3.13.1
|
||||||
@ -20,6 +22,7 @@ require (
|
|||||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
||||||
github.com/rivo/uniseg v0.4.4 // indirect
|
github.com/rivo/uniseg v0.4.4 // indirect
|
||||||
|
github.com/stretchr/testify v1.8.2 // indirect
|
||||||
golang.org/x/net v0.9.0 // indirect
|
golang.org/x/net v0.9.0 // indirect
|
||||||
golang.org/x/sys v0.7.0 // indirect
|
golang.org/x/sys v0.7.0 // indirect
|
||||||
golang.org/x/term v0.7.0 // indirect
|
golang.org/x/term v0.7.0 // indirect
|
||||||
|
18
go.sum
18
go.sum
@ -1,3 +1,5 @@
|
|||||||
|
github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=
|
||||||
|
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -5,6 +7,8 @@ github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvd
|
|||||||
github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
|
github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||||
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||||
@ -31,15 +35,18 @@ github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
|
|||||||
github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE=
|
github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE=
|
||||||
github.com/schollz/progressbar/v3 v3.13.1/go.mod h1:xvrbki8kfT1fzWzBT/UZd9L6GA+jdL7HAgq2RFnO6fQ=
|
github.com/schollz/progressbar/v3 v3.13.1/go.mod h1:xvrbki8kfT1fzWzBT/UZd9L6GA+jdL7HAgq2RFnO6fQ=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
|
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k=
|
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k=
|
||||||
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM=
|
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/image v0.6.0 h1:bR8b5okrPI3g/gyZakLZHeWxAR8Dn5CyxXv1hLH5g/4=
|
|
||||||
golang.org/x/image v0.6.0/go.mod h1:MXLdDR43H7cDJq5GEGXEVeeNhPgi+YYEQ2pC1byI1x0=
|
|
||||||
golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw=
|
golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw=
|
||||||
golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg=
|
golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
@ -47,7 +54,6 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
|||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
|
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||||
@ -61,14 +67,12 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
|
|
||||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||||
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
||||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
||||||
@ -76,7 +80,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
@ -86,5 +89,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@ -79,9 +79,6 @@ func (c *Converter) InitParse() {
|
|||||||
c.AddStringParam(&c.Options.Output, "output", "", "Output of the epub (directory or epub): (default [INPUT].epub)")
|
c.AddStringParam(&c.Options.Output, "output", "", "Output of the epub (directory or epub): (default [INPUT].epub)")
|
||||||
c.AddStringParam(&c.Options.Author, "author", "GO Comic Converter", "Author of the epub")
|
c.AddStringParam(&c.Options.Author, "author", "GO Comic Converter", "Author of the epub")
|
||||||
c.AddStringParam(&c.Options.Title, "title", "", "Title of the epub")
|
c.AddStringParam(&c.Options.Title, "title", "", "Title of the epub")
|
||||||
c.AddIntParam(&c.Options.Workers, "workers", runtime.NumCPU(), "Number of workers")
|
|
||||||
c.AddBoolParam(&c.Options.Dry, "dry", false, "Dry run to show all options")
|
|
||||||
c.AddBoolParam(&c.Options.DryVerbose, "dry-verbose", false, "Display also sorted files after the TOC")
|
|
||||||
|
|
||||||
c.AddSection("Config")
|
c.AddSection("Config")
|
||||||
c.AddStringParam(&c.Options.Profile, "profile", c.Options.Profile, fmt.Sprintf("Profile to use: \n%s", c.Options.AvailableProfiles()))
|
c.AddStringParam(&c.Options.Profile, "profile", c.Options.Profile, fmt.Sprintf("Profile to use: \n%s", c.Options.AvailableProfiles()))
|
||||||
@ -95,7 +92,6 @@ func (c *Converter) InitParse() {
|
|||||||
c.AddBoolParam(&c.Options.NoBlankPage, "noblankpage", c.Options.NoBlankPage, "Remove blank pages")
|
c.AddBoolParam(&c.Options.NoBlankPage, "noblankpage", c.Options.NoBlankPage, "Remove blank pages")
|
||||||
c.AddBoolParam(&c.Options.Manga, "manga", c.Options.Manga, "Manga mode (right to left)")
|
c.AddBoolParam(&c.Options.Manga, "manga", c.Options.Manga, "Manga mode (right to left)")
|
||||||
c.AddBoolParam(&c.Options.HasCover, "hascover", c.Options.HasCover, "Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.")
|
c.AddBoolParam(&c.Options.HasCover, "hascover", c.Options.HasCover, "Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.")
|
||||||
c.AddBoolParam(&c.Options.AddPanelView, "addpanelview", c.Options.AddPanelView, "Add an embeded panel view. On kindle you may not need this option as it is handled by the kindle.")
|
|
||||||
c.AddIntParam(&c.Options.LimitMb, "limitmb", c.Options.LimitMb, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
c.AddIntParam(&c.Options.LimitMb, "limitmb", c.Options.LimitMb, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
||||||
c.AddBoolParam(&c.Options.StripFirstDirectoryFromToc, "strip", c.Options.StripFirstDirectoryFromToc, "Strip first directory from the TOC if only 1")
|
c.AddBoolParam(&c.Options.StripFirstDirectoryFromToc, "strip", c.Options.StripFirstDirectoryFromToc, "Strip first directory from the TOC if only 1")
|
||||||
c.AddIntParam(&c.Options.SortPathMode, "sort", c.Options.SortPathMode, "Sort path mode\n0 = alpha for path and file\n1 = alphanum for path and alpha for file\n2 = alphanum for path and file")
|
c.AddIntParam(&c.Options.SortPathMode, "sort", c.Options.SortPathMode, "Sort path mode\n0 = alpha for path and file\n1 = alphanum for path and alpha for file\n2 = alphanum for path and file")
|
||||||
@ -106,6 +102,10 @@ func (c *Converter) InitParse() {
|
|||||||
c.AddBoolParam(&c.Options.Reset, "reset", false, "Reset your parameters to default")
|
c.AddBoolParam(&c.Options.Reset, "reset", false, "Reset your parameters to default")
|
||||||
|
|
||||||
c.AddSection("Other")
|
c.AddSection("Other")
|
||||||
|
c.AddIntParam(&c.Options.Workers, "workers", runtime.NumCPU(), "Number of workers")
|
||||||
|
c.AddBoolParam(&c.Options.Dry, "dry", false, "Dry run to show all options")
|
||||||
|
c.AddBoolParam(&c.Options.DryVerbose, "dry-verbose", false, "Display also sorted files after the TOC")
|
||||||
|
c.AddBoolParam(&c.Options.Quiet, "quiet", false, "Disable progress bar")
|
||||||
c.AddBoolParam(&c.Options.Version, "version", false, "Show current and available version")
|
c.AddBoolParam(&c.Options.Version, "version", false, "Show current and available version")
|
||||||
c.AddBoolParam(&c.Options.Help, "help", false, "Show this help message")
|
c.AddBoolParam(&c.Options.Help, "help", false, "Show this help message")
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/celogeek/go-comic-converter/v2/internal/converter/profiles"
|
"github.com/celogeek/go-comic-converter/v2/internal/converter/profiles"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -11,14 +12,10 @@ import (
|
|||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// Output
|
// Output
|
||||||
Input string `yaml:"-"`
|
Input string `yaml:"-"`
|
||||||
Output string `yaml:"-"`
|
Output string `yaml:"-"`
|
||||||
Author string `yaml:"-"`
|
Author string `yaml:"-"`
|
||||||
Title string `yaml:"-"`
|
Title string `yaml:"-"`
|
||||||
Auto bool `yaml:"-"`
|
|
||||||
Workers int `yaml:"-"`
|
|
||||||
Dry bool `yaml:"-"`
|
|
||||||
DryVerbose bool `yaml:"-"`
|
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
Profile string `yaml:"profile"`
|
Profile string `yaml:"profile"`
|
||||||
@ -26,12 +23,12 @@ type Options struct {
|
|||||||
Crop bool `yaml:"crop"`
|
Crop bool `yaml:"crop"`
|
||||||
Brightness int `yaml:"brightness"`
|
Brightness int `yaml:"brightness"`
|
||||||
Contrast int `yaml:"contrast"`
|
Contrast int `yaml:"contrast"`
|
||||||
|
Auto bool `yaml:"-"`
|
||||||
AutoRotate bool `yaml:"auto_rotate"`
|
AutoRotate bool `yaml:"auto_rotate"`
|
||||||
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
||||||
NoBlankPage bool `yaml:"no_blank_page"`
|
NoBlankPage bool `yaml:"no_blank_page"`
|
||||||
Manga bool `yaml:"manga"`
|
Manga bool `yaml:"manga"`
|
||||||
HasCover bool `yaml:"has_cover"`
|
HasCover bool `yaml:"has_cover"`
|
||||||
AddPanelView bool `yaml:"add_panel_view"`
|
|
||||||
LimitMb int `yaml:"limit_mb"`
|
LimitMb int `yaml:"limit_mb"`
|
||||||
StripFirstDirectoryFromToc bool `yaml:"strip_first_directory_from_toc"`
|
StripFirstDirectoryFromToc bool `yaml:"strip_first_directory_from_toc"`
|
||||||
SortPathMode int `yaml:"sort_path_mode"`
|
SortPathMode int `yaml:"sort_path_mode"`
|
||||||
@ -42,8 +39,12 @@ type Options struct {
|
|||||||
Reset bool `yaml:"-"`
|
Reset bool `yaml:"-"`
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
Version bool `yaml:"-"`
|
Workers int `yaml:"-"`
|
||||||
Help bool `yaml:"-"`
|
Dry bool `yaml:"-"`
|
||||||
|
DryVerbose bool `yaml:"-"`
|
||||||
|
Quiet bool `yaml:"-"`
|
||||||
|
Version bool `yaml:"-"`
|
||||||
|
Help bool `yaml:"-"`
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
profiles profiles.Profiles
|
profiles profiles.Profiles
|
||||||
@ -61,7 +62,6 @@ func New() *Options {
|
|||||||
NoBlankPage: false,
|
NoBlankPage: false,
|
||||||
Manga: false,
|
Manga: false,
|
||||||
HasCover: true,
|
HasCover: true,
|
||||||
AddPanelView: false,
|
|
||||||
LimitMb: 0,
|
LimitMb: 0,
|
||||||
StripFirstDirectoryFromToc: false,
|
StripFirstDirectoryFromToc: false,
|
||||||
SortPathMode: 1,
|
SortPathMode: 1,
|
||||||
@ -113,7 +113,7 @@ func (o *Options) LoadDefault() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Options) ShowDefault() string {
|
func (o *Options) ShowDefault() string {
|
||||||
var profileDesc string
|
var profileDesc, viewDesc string
|
||||||
profile := o.GetProfile()
|
profile := o.GetProfile()
|
||||||
if profile != nil {
|
if profile != nil {
|
||||||
profileDesc = fmt.Sprintf(
|
profileDesc = fmt.Sprintf(
|
||||||
@ -123,6 +123,13 @@ func (o *Options) ShowDefault() string {
|
|||||||
profile.Width,
|
profile.Width,
|
||||||
profile.Height,
|
profile.Height,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
perfectWidth, perfectHeight := profile.PerfectDim()
|
||||||
|
viewDesc = fmt.Sprintf(
|
||||||
|
"%dx%d",
|
||||||
|
perfectWidth,
|
||||||
|
perfectHeight,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
limitmb := "nolimit"
|
limitmb := "nolimit"
|
||||||
if o.LimitMb > 0 {
|
if o.LimitMb > 0 {
|
||||||
@ -141,6 +148,8 @@ func (o *Options) ShowDefault() string {
|
|||||||
|
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
Profile : %s
|
Profile : %s
|
||||||
|
ViewRatio : 1:%s
|
||||||
|
View : %s
|
||||||
Quality : %d
|
Quality : %d
|
||||||
Crop : %v
|
Crop : %v
|
||||||
Brightness : %d
|
Brightness : %d
|
||||||
@ -150,11 +159,12 @@ func (o *Options) ShowDefault() string {
|
|||||||
NoBlankPage : %v
|
NoBlankPage : %v
|
||||||
Manga : %v
|
Manga : %v
|
||||||
HasCover : %v
|
HasCover : %v
|
||||||
AddPanelView : %v
|
|
||||||
LimitMb : %s
|
LimitMb : %s
|
||||||
StripFirstDirectoryFromToc: %v
|
StripFirstDirectoryFromToc: %v
|
||||||
SortPathMode : %s`,
|
SortPathMode : %s`,
|
||||||
profileDesc,
|
profileDesc,
|
||||||
|
strings.TrimRight(fmt.Sprintf("%f", profiles.PerfectRatio), "0"),
|
||||||
|
viewDesc,
|
||||||
o.Quality,
|
o.Quality,
|
||||||
o.Crop,
|
o.Crop,
|
||||||
o.Brightness,
|
o.Brightness,
|
||||||
@ -164,7 +174,6 @@ func (o *Options) ShowDefault() string {
|
|||||||
o.NoBlankPage,
|
o.NoBlankPage,
|
||||||
o.Manga,
|
o.Manga,
|
||||||
o.HasCover,
|
o.HasCover,
|
||||||
o.AddPanelView,
|
|
||||||
limitmb,
|
limitmb,
|
||||||
o.StripFirstDirectoryFromToc,
|
o.StripFirstDirectoryFromToc,
|
||||||
sortpathmode,
|
sortpathmode,
|
@ -12,6 +12,19 @@ type Profile struct {
|
|||||||
Height int
|
Height int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PerfectRatio = 1.5
|
||||||
|
|
||||||
|
func (p Profile) PerfectDim() (int, int) {
|
||||||
|
width, height := float64(p.Width), float64(p.Height)
|
||||||
|
perfectWidth, perfectHeight := height/PerfectRatio, width*PerfectRatio
|
||||||
|
if perfectWidth > width {
|
||||||
|
perfectWidth = width
|
||||||
|
} else {
|
||||||
|
perfectHeight = height
|
||||||
|
}
|
||||||
|
return int(perfectWidth), int(perfectHeight)
|
||||||
|
}
|
||||||
|
|
||||||
type Profiles []Profile
|
type Profiles []Profile
|
||||||
|
|
||||||
func New() Profiles {
|
func New() Profiles {
|
@ -1,7 +1,6 @@
|
|||||||
package epub
|
package epub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -27,7 +26,6 @@ type ImageOptions struct {
|
|||||||
NoBlankPage bool
|
NoBlankPage bool
|
||||||
Manga bool
|
Manga bool
|
||||||
HasCover bool
|
HasCover bool
|
||||||
AddPanelView bool
|
|
||||||
Workers int
|
Workers int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +39,7 @@ type EpubOptions struct {
|
|||||||
Dry bool
|
Dry bool
|
||||||
DryVerbose bool
|
DryVerbose bool
|
||||||
SortPathMode int
|
SortPathMode int
|
||||||
|
Quiet bool
|
||||||
|
|
||||||
*ImageOptions
|
*ImageOptions
|
||||||
}
|
}
|
||||||
@ -95,6 +94,34 @@ func (e *ePub) render(templateString string, data any) string {
|
|||||||
return stripBlank.ReplaceAllString(result.String(), "\n")
|
return stripBlank.ReplaceAllString(result.String(), "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *ePub) writeImage(wz *epubZip, img *Image) error {
|
||||||
|
err := wz.WriteFile(
|
||||||
|
fmt.Sprintf("OEBPS/%s", img.TextPath()),
|
||||||
|
e.render(textTmpl, map[string]any{
|
||||||
|
"Title": fmt.Sprintf("Image %d Part %d", img.Id, img.Part),
|
||||||
|
"ViewPort": fmt.Sprintf("width=%d,height=%d", e.ViewWidth, e.ViewHeight),
|
||||||
|
"ImagePath": img.ImgPath(),
|
||||||
|
"ImageStyle": img.ImgStyle(e.ViewWidth, e.ViewHeight, e.Manga),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
err = wz.WriteImage(img.Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ePub) writeBlank(wz *epubZip, img *Image) error {
|
||||||
|
return wz.WriteFile(
|
||||||
|
fmt.Sprintf("OEBPS/Text/%d_sp.xhtml", img.Id),
|
||||||
|
e.render(blankTmpl, map[string]any{
|
||||||
|
"Title": fmt.Sprintf("Blank Page %d", img.Id),
|
||||||
|
"ViewPort": fmt.Sprintf("width=%d,height=%d", e.ViewWidth, e.ViewHeight),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func (e *ePub) getParts() ([]*epubPart, error) {
|
func (e *ePub) getParts() ([]*epubPart, error) {
|
||||||
images, err := e.LoadImages()
|
images, err := e.LoadImages()
|
||||||
|
|
||||||
@ -129,13 +156,15 @@ func (e *ePub) getParts() ([]*epubPart, error) {
|
|||||||
maxSize := uint64(e.LimitMb * 1024 * 1024)
|
maxSize := uint64(e.LimitMb * 1024 * 1024)
|
||||||
|
|
||||||
xhtmlSize := uint64(1024)
|
xhtmlSize := uint64(1024)
|
||||||
// descriptor files + image
|
// descriptor files + title
|
||||||
baseSize := uint64(16*1024) + cover.Data.CompressedSize()
|
baseSize := uint64(16*1024) + cover.Data.CompressedSize()
|
||||||
|
if e.HasCover {
|
||||||
|
baseSize += cover.Data.CompressedSize()
|
||||||
|
}
|
||||||
|
|
||||||
currentSize := baseSize
|
currentSize := baseSize
|
||||||
currentImages := make([]*Image, 0)
|
currentImages := make([]*Image, 0)
|
||||||
part := 1
|
part := 1
|
||||||
imgIsOnRightSide := false
|
|
||||||
|
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
imgSize := img.Data.CompressedSize() + xhtmlSize
|
imgSize := img.Data.CompressedSize() + xhtmlSize
|
||||||
@ -145,14 +174,14 @@ func (e *ePub) getParts() ([]*epubPart, error) {
|
|||||||
Images: currentImages,
|
Images: currentImages,
|
||||||
})
|
})
|
||||||
part += 1
|
part += 1
|
||||||
imgIsOnRightSide = false
|
|
||||||
currentSize = baseSize
|
currentSize = baseSize
|
||||||
|
if !e.HasCover {
|
||||||
|
currentSize += cover.Data.CompressedSize()
|
||||||
|
}
|
||||||
currentImages = make([]*Image, 0)
|
currentImages = make([]*Image, 0)
|
||||||
}
|
}
|
||||||
currentSize += imgSize
|
currentSize += imgSize
|
||||||
img.NeedSpace = img.Part == 1 && imgIsOnRightSide
|
|
||||||
currentImages = append(currentImages, img)
|
currentImages = append(currentImages, img)
|
||||||
imgIsOnRightSide = !imgIsOnRightSide
|
|
||||||
}
|
}
|
||||||
if len(currentImages) > 0 {
|
if len(currentImages) > 0 {
|
||||||
parts = append(parts, &epubPart{
|
parts = append(parts, &epubPart{
|
||||||
@ -164,59 +193,6 @@ func (e *ePub) getParts() ([]*epubPart, error) {
|
|||||||
return parts, nil
|
return parts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ePub) getToc(images []*Image) *TocChildren {
|
|
||||||
paths := map[string]*TocPart{
|
|
||||||
".": {},
|
|
||||||
}
|
|
||||||
for _, img := range images {
|
|
||||||
currentPath := "."
|
|
||||||
for _, path := range strings.Split(img.Path, string(filepath.Separator)) {
|
|
||||||
parentPath := currentPath
|
|
||||||
currentPath = filepath.Join(currentPath, path)
|
|
||||||
if _, ok := paths[currentPath]; ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
part := &TocPart{
|
|
||||||
Title: TocTitle{
|
|
||||||
Value: path,
|
|
||||||
Link: fmt.Sprintf("Text/%d_p%d.xhtml", img.Id, img.Part),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
paths[currentPath] = part
|
|
||||||
if paths[parentPath].Children == nil {
|
|
||||||
paths[parentPath].Children = &TocChildren{}
|
|
||||||
}
|
|
||||||
paths[parentPath].Children.Tags = append(paths[parentPath].Children.Tags, part)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
children := paths["."].Children
|
|
||||||
|
|
||||||
if children != nil && e.StripFirstDirectoryFromToc && len(children.Tags) == 1 {
|
|
||||||
children = children.Tags[0].Children
|
|
||||||
}
|
|
||||||
|
|
||||||
return children
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *ePub) getTree(images []*Image, skip_files bool) string {
|
|
||||||
t := NewTree()
|
|
||||||
for _, img := range images {
|
|
||||||
if skip_files {
|
|
||||||
t.Add(img.Path)
|
|
||||||
} else {
|
|
||||||
t.Add(filepath.Join(img.Path, img.Name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c := t.Root()
|
|
||||||
if skip_files && e.StripFirstDirectoryFromToc && len(c.Children) == 1 {
|
|
||||||
c = c.Children[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.toString("")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *ePub) Write() error {
|
func (e *ePub) Write() error {
|
||||||
type zipContent struct {
|
type zipContent struct {
|
||||||
Name string
|
Name string
|
||||||
@ -242,7 +218,7 @@ func (e *ePub) Write() error {
|
|||||||
|
|
||||||
totalParts := len(epubParts)
|
totalParts := len(epubParts)
|
||||||
|
|
||||||
bar := NewBar(totalParts, "Writing Part", 2, 2)
|
bar := NewBar(e.Quiet, totalParts, "Writing Part", 2, 2)
|
||||||
for i, part := range epubParts {
|
for i, part := range epubParts {
|
||||||
ext := filepath.Ext(e.Output)
|
ext := filepath.Ext(e.Output)
|
||||||
suffix := ""
|
suffix := ""
|
||||||
@ -264,42 +240,21 @@ func (e *ePub) Write() error {
|
|||||||
title = fmt.Sprintf("%s [%d/%d]", title, i+1, totalParts)
|
title = fmt.Sprintf("%s [%d/%d]", title, i+1, totalParts)
|
||||||
}
|
}
|
||||||
|
|
||||||
tocChildren := e.getToc(part.Images)
|
|
||||||
toc := []byte{}
|
|
||||||
if tocChildren != nil {
|
|
||||||
toc, err = xml.MarshalIndent(tocChildren.Tags, " ", " ")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
content := []zipContent{
|
content := []zipContent{
|
||||||
{"META-INF/container.xml", containerTmpl},
|
{"META-INF/container.xml", containerTmpl},
|
||||||
{"OEBPS/content.opf", e.render(contentTmpl, map[string]any{
|
{"META-INF/com.apple.ibooks.display-options.xml", appleBooksTmpl},
|
||||||
"Info": e,
|
{"OEBPS/content.opf", e.getContent(title, part, i+1, totalParts).String()},
|
||||||
"Cover": part.Cover,
|
{"OEBPS/toc.xhtml", e.getToc(title, part.Images)},
|
||||||
"Images": part.Images,
|
{"OEBPS/Text/style.css", e.render(styleTmpl, map[string]any{
|
||||||
"Title": title,
|
"PageWidth": e.ViewWidth,
|
||||||
"Part": i + 1,
|
"PageHeight": e.ViewHeight,
|
||||||
"Total": totalParts,
|
|
||||||
})},
|
})},
|
||||||
{"OEBPS/toc.ncx", e.render(tocTmpl, map[string]any{
|
{"OEBPS/Text/title.xhtml", e.render(textTmpl, map[string]any{
|
||||||
"Info": e,
|
"Title": title,
|
||||||
"Title": title,
|
"ViewPort": fmt.Sprintf("width=%d,height=%d", e.ViewWidth, e.ViewHeight),
|
||||||
|
"ImagePath": "Images/title.jpg",
|
||||||
|
"ImageStyle": part.Cover.ImgStyle(e.ViewWidth, e.ViewHeight, e.Manga),
|
||||||
})},
|
})},
|
||||||
{"OEBPS/nav.xhtml", e.render(navTmpl, map[string]any{
|
|
||||||
"Title": title,
|
|
||||||
"TOC": string(toc),
|
|
||||||
})},
|
|
||||||
{"OEBPS/Text/style.css", styleTmpl},
|
|
||||||
{"OEBPS/Text/part.xhtml", e.render(partTmpl, map[string]any{
|
|
||||||
"Info": e,
|
|
||||||
"Part": i + 1,
|
|
||||||
"Total": totalParts,
|
|
||||||
})},
|
|
||||||
}
|
|
||||||
if e.AddPanelView {
|
|
||||||
content = append(content, zipContent{"OEBPS/Text/panelview.css", panelViewTmpl})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = wz.WriteMagic(); err != nil {
|
if err = wz.WriteMagic(); err != nil {
|
||||||
@ -310,45 +265,29 @@ func (e *ePub) Write() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := wz.WriteImage(e.createTitleImageDate(title, part.Cover, i+1, totalParts)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Cover exist or part > 1
|
// Cover exist or part > 1
|
||||||
// If no cover, part 2 and more will include the image as a cover
|
// If no cover, part 2 and more will include the image as a cover
|
||||||
if e.HasCover || i > 0 {
|
if e.HasCover || i > 0 {
|
||||||
wz.WriteImage(part.Cover.Data)
|
if err := e.writeImage(wz, part.Cover); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, img := range part.Images {
|
for i, img := range part.Images {
|
||||||
var content string
|
if err := e.writeImage(wz, img); err != nil {
|
||||||
if e.AddPanelView {
|
|
||||||
content = e.render(textTmpl, map[string]any{
|
|
||||||
"Image": img,
|
|
||||||
"Manga": e.Manga,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
content = e.render(textNoPanelTmpl, map[string]any{
|
|
||||||
"Image": img,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := wz.WriteFile(fmt.Sprintf("OEBPS/Text/%d_p%d.xhtml", img.Id, img.Part), content); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if img.NeedSpace {
|
// Double Page or Last Image
|
||||||
if err := wz.WriteFile(
|
if img.DoublePage || (i+1 == len(part.Images)) {
|
||||||
fmt.Sprintf("OEBPS/Text/%d_sp.xhtml", img.Id),
|
if err := e.writeBlank(wz, img); err != nil {
|
||||||
e.render(blankTmpl, map[string]any{
|
|
||||||
"Info": e,
|
|
||||||
"Image": img,
|
|
||||||
}),
|
|
||||||
); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := wz.WriteImage(img.Data); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bar.Add(1)
|
bar.Add(1)
|
||||||
}
|
}
|
201
internal/epub/epub_content.go
Normal file
201
internal/epub/epub_content.go
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
package epub
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/beevik/etree"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Content struct {
|
||||||
|
doc *etree.Document
|
||||||
|
}
|
||||||
|
|
||||||
|
type TagAttrs map[string]string
|
||||||
|
|
||||||
|
type Tag struct {
|
||||||
|
name string
|
||||||
|
attrs TagAttrs
|
||||||
|
value string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ePub) getMeta(title string, part *epubPart, currentPart, totalPart int) []Tag {
|
||||||
|
metas := []Tag{
|
||||||
|
{"meta", TagAttrs{"property": "dcterms:modified"}, e.UpdatedAt},
|
||||||
|
{"meta", TagAttrs{"property": "rendition:layout"}, "pre-paginated"},
|
||||||
|
{"meta", TagAttrs{"property": "rendition:spread"}, "auto"},
|
||||||
|
{"meta", TagAttrs{"property": "rendition:orientation"}, "auto"},
|
||||||
|
{"meta", TagAttrs{"property": "schema:accessMode"}, "visual"},
|
||||||
|
{"meta", TagAttrs{"property": "schema:accessModeSufficient"}, "visual"},
|
||||||
|
{"meta", TagAttrs{"property": "schema:accessibilityHazard"}, "noFlashingHazard"},
|
||||||
|
{"meta", TagAttrs{"property": "schema:accessibilityHazard"}, "noMotionSimulationHazard"},
|
||||||
|
{"meta", TagAttrs{"property": "schema:accessibilityHazard"}, "noSoundHazard"},
|
||||||
|
{"meta", TagAttrs{"name": "book-type", "content": "comic"}, ""},
|
||||||
|
{"opf:meta", TagAttrs{"name": "fixed-layout", "content": "true"}, ""},
|
||||||
|
{"opf:meta", TagAttrs{"name": "original-resolution", "content": fmt.Sprintf("%dx%d", e.ViewWidth, e.ViewHeight)}, ""},
|
||||||
|
{"dc:title", TagAttrs{}, title},
|
||||||
|
{"dc:identifier", TagAttrs{"id": "ean"}, fmt.Sprintf("urn:uuid:%s", e.UID)},
|
||||||
|
{"dc:language", TagAttrs{}, "en"},
|
||||||
|
{"dc:creator", TagAttrs{}, e.Author},
|
||||||
|
{"dc:publisher", TagAttrs{}, e.Publisher},
|
||||||
|
{"dc:contributor", TagAttrs{}, "Go Comic Convertor"},
|
||||||
|
{"dc:date", TagAttrs{}, e.UpdatedAt},
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.Manga {
|
||||||
|
metas = append(metas, Tag{"meta", TagAttrs{"name": "primary-writing-mode", "content": "horizontal-rl"}, ""})
|
||||||
|
} else {
|
||||||
|
metas = append(metas, Tag{"meta", TagAttrs{"name": "primary-writing-mode", "content": "horizontal-lr"}, ""})
|
||||||
|
}
|
||||||
|
|
||||||
|
if part.Cover != nil {
|
||||||
|
metas = append(metas, Tag{"meta", TagAttrs{"name": "cover", "content": part.Cover.Key("img")}, ""})
|
||||||
|
}
|
||||||
|
|
||||||
|
if totalPart > 1 {
|
||||||
|
metas = append(
|
||||||
|
metas,
|
||||||
|
Tag{"meta", TagAttrs{"name": "calibre:series", "content": e.Title}, ""},
|
||||||
|
Tag{"meta", TagAttrs{"name": "calibre:series_index", "content": fmt.Sprint(currentPart)}, ""},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return metas
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ePub) getManifest(title string, part *epubPart, currentPart, totalPart int) []Tag {
|
||||||
|
iTag := func(img *Image) Tag {
|
||||||
|
return Tag{"item", TagAttrs{"id": img.Key("img"), "href": img.ImgPath(), "media-type": "image/jpeg"}, ""}
|
||||||
|
}
|
||||||
|
hTag := func(img *Image) Tag {
|
||||||
|
return Tag{"item", TagAttrs{"id": img.Key("page"), "href": img.TextPath(), "media-type": "application/xhtml+xml"}, ""}
|
||||||
|
}
|
||||||
|
sTag := func(img *Image) Tag {
|
||||||
|
return Tag{"item", TagAttrs{"id": img.SpaceKey("page"), "href": img.SpacePath(), "media-type": "application/xhtml+xml"}, ""}
|
||||||
|
}
|
||||||
|
items := []Tag{
|
||||||
|
{"item", TagAttrs{"id": "toc", "href": "toc.xhtml", "properties": "nav", "media-type": "application/xhtml+xml"}, ""},
|
||||||
|
{"item", TagAttrs{"id": "css", "href": "Text/style.css", "media-type": "text/css"}, ""},
|
||||||
|
{"item", TagAttrs{"id": "page_title", "href": "Text/title.xhtml", "media-type": "application/xhtml+xml"}, ""},
|
||||||
|
{"item", TagAttrs{"id": "img_title", "href": "Images/title.jpg", "media-type": "image/jpeg"}, ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.HasCover || currentPart > 1 {
|
||||||
|
items = append(items, iTag(part.Cover), hTag(part.Cover))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, img := range part.Images {
|
||||||
|
if img.Part == 1 {
|
||||||
|
items = append(items, sTag(img))
|
||||||
|
}
|
||||||
|
items = append(items, iTag(img), hTag(img))
|
||||||
|
}
|
||||||
|
items = append(items, sTag(part.Images[len(part.Images)-1]))
|
||||||
|
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ePub) getSpine(title string, part *epubPart, currentPart, totalPart int) []Tag {
|
||||||
|
isOnTheRight := !e.Manga
|
||||||
|
getSpread := func(doublePageNoBlank bool) string {
|
||||||
|
isOnTheRight = !isOnTheRight
|
||||||
|
if doublePageNoBlank {
|
||||||
|
// Center the double page then start back to comic mode (mange/normal)
|
||||||
|
isOnTheRight = !e.Manga
|
||||||
|
return "rendition:page-spread-center"
|
||||||
|
}
|
||||||
|
if isOnTheRight {
|
||||||
|
return "rendition:page-spread-right"
|
||||||
|
} else {
|
||||||
|
return "rendition:page-spread-left"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
spine := []Tag{
|
||||||
|
{"itemref", TagAttrs{"idref": "page_title", "properties": getSpread(true)}, ""},
|
||||||
|
}
|
||||||
|
for _, img := range part.Images {
|
||||||
|
spine = append(spine, Tag{
|
||||||
|
"itemref",
|
||||||
|
TagAttrs{"idref": img.Key("page"), "properties": getSpread(img.DoublePage && e.NoBlankPage)},
|
||||||
|
"",
|
||||||
|
})
|
||||||
|
if img.DoublePage && isOnTheRight && !e.NoBlankPage {
|
||||||
|
spine = append(spine, Tag{
|
||||||
|
"itemref",
|
||||||
|
TagAttrs{"idref": img.SpaceKey("page"), "properties": getSpread(false)},
|
||||||
|
"",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if e.Manga == isOnTheRight {
|
||||||
|
spine = append(spine, Tag{
|
||||||
|
"itemref",
|
||||||
|
TagAttrs{"idref": part.Images[len(part.Images)-1].SpaceKey("page"), "properties": getSpread(false)},
|
||||||
|
"",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return spine
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ePub) getGuide(title string, part *epubPart, currentPart, totalPart int) []Tag {
|
||||||
|
guide := []Tag{}
|
||||||
|
if part.Cover != nil {
|
||||||
|
guide = append(guide, Tag{"reference", TagAttrs{"type": "cover", "title": "cover", "href": part.Cover.TextPath()}, ""})
|
||||||
|
}
|
||||||
|
guide = append(guide, Tag{"reference", TagAttrs{"type": "text", "title": "content", "href": part.Images[0].TextPath()}, ""})
|
||||||
|
return guide
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ePub) getContent(title string, part *epubPart, currentPart, totalPart int) *Content {
|
||||||
|
doc := etree.NewDocument()
|
||||||
|
doc.CreateProcInst("xml", `version="1.0" encoding="UTF-8"`)
|
||||||
|
|
||||||
|
pkg := doc.CreateElement("package")
|
||||||
|
pkg.CreateAttr("xmlns", "http://www.idpf.org/2007/opf")
|
||||||
|
pkg.CreateAttr("unique-identifier", "ean")
|
||||||
|
pkg.CreateAttr("version", "3.0")
|
||||||
|
pkg.CreateAttr("prefix", "rendition: http://www.idpf.org/vocab/rendition/#")
|
||||||
|
|
||||||
|
addToElement := func(elm *etree.Element, meth func(title string, part *epubPart, currentPart, totalPart int) []Tag) {
|
||||||
|
for _, p := range meth(title, part, currentPart, totalPart) {
|
||||||
|
meta := elm.CreateElement(p.name)
|
||||||
|
for k, v := range p.attrs {
|
||||||
|
meta.CreateAttr(k, v)
|
||||||
|
}
|
||||||
|
meta.SortAttrs()
|
||||||
|
if p.value != "" {
|
||||||
|
meta.CreateText(p.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metadata := pkg.CreateElement("metadata")
|
||||||
|
metadata.CreateAttr("xmlns:dc", "http://purl.org/dc/elements/1.1/")
|
||||||
|
metadata.CreateAttr("xmlns:opf", "http://www.idpf.org/2007/opf")
|
||||||
|
addToElement(metadata, e.getMeta)
|
||||||
|
|
||||||
|
manifest := pkg.CreateElement("manifest")
|
||||||
|
addToElement(manifest, e.getManifest)
|
||||||
|
|
||||||
|
spine := pkg.CreateElement("spine")
|
||||||
|
if e.Manga {
|
||||||
|
spine.CreateAttr("page-progression-direction", "rtl")
|
||||||
|
} else {
|
||||||
|
spine.CreateAttr("page-progression-direction", "ltr")
|
||||||
|
}
|
||||||
|
addToElement(spine, e.getSpine)
|
||||||
|
|
||||||
|
guide := pkg.CreateElement("guide")
|
||||||
|
addToElement(guide, e.getGuide)
|
||||||
|
|
||||||
|
return &Content{
|
||||||
|
doc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Content) String() string {
|
||||||
|
c.doc.Indent(2)
|
||||||
|
r, _ := c.doc.WriteToString()
|
||||||
|
return r
|
||||||
|
}
|
@ -22,6 +22,10 @@ func (img *ImageData) CompressedSize() uint64 {
|
|||||||
|
|
||||||
func newImageData(id int, part int, img image.Image, quality int) *ImageData {
|
func newImageData(id int, part int, img image.Image, quality int) *ImageData {
|
||||||
name := fmt.Sprintf("OEBPS/Images/%d_p%d.jpg", id, part)
|
name := fmt.Sprintf("OEBPS/Images/%d_p%d.jpg", id, part)
|
||||||
|
return newData(name, img, quality)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newData(name string, img image.Image, quality int) *ImageData {
|
||||||
data := bytes.NewBuffer([]byte{})
|
data := bytes.NewBuffer([]byte{})
|
||||||
if err := jpeg.Encode(data, img, &jpeg.Options{Quality: quality}); err != nil {
|
if err := jpeg.Encode(data, img, &jpeg.Options{Quality: quality}); err != nil {
|
||||||
panic(err)
|
panic(err)
|
@ -28,14 +28,12 @@ func NewGift(options *ImageOptions) *gift.GIFT {
|
|||||||
func NewGiftSplitDoublePage(options *ImageOptions) []*gift.GIFT {
|
func NewGiftSplitDoublePage(options *ImageOptions) []*gift.GIFT {
|
||||||
gifts := make([]*gift.GIFT, 2)
|
gifts := make([]*gift.GIFT, 2)
|
||||||
|
|
||||||
rightFirst := options.Manga
|
|
||||||
|
|
||||||
gifts[0] = gift.New(
|
gifts[0] = gift.New(
|
||||||
filters.CropSplitDoublePage(rightFirst),
|
filters.CropSplitDoublePage(options.Manga),
|
||||||
)
|
)
|
||||||
|
|
||||||
gifts[1] = gift.New(
|
gifts[1] = gift.New(
|
||||||
filters.CropSplitDoublePage(!rightFirst),
|
filters.CropSplitDoublePage(!options.Manga),
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, g := range gifts {
|
for _, g := range gifts {
|
||||||
@ -45,8 +43,9 @@ func NewGiftSplitDoublePage(options *ImageOptions) []*gift.GIFT {
|
|||||||
if options.Brightness != 0 {
|
if options.Brightness != 0 {
|
||||||
g.Add(gift.Brightness(float32(options.Brightness)))
|
g.Add(gift.Brightness(float32(options.Brightness)))
|
||||||
}
|
}
|
||||||
|
|
||||||
g.Add(
|
g.Add(
|
||||||
gift.ResizeToFit(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
|
filters.Resize(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
"image/draw"
|
||||||
_ "image/jpeg"
|
_ "image/jpeg"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"io"
|
"io"
|
||||||
@ -18,23 +19,78 @@ import (
|
|||||||
|
|
||||||
"github.com/celogeek/go-comic-converter/v2/internal/epub/sortpath"
|
"github.com/celogeek/go-comic-converter/v2/internal/epub/sortpath"
|
||||||
"github.com/disintegration/gift"
|
"github.com/disintegration/gift"
|
||||||
|
"github.com/golang/freetype"
|
||||||
|
"github.com/golang/freetype/truetype"
|
||||||
"github.com/nwaples/rardecode"
|
"github.com/nwaples/rardecode"
|
||||||
pdfimage "github.com/raff/pdfreader/image"
|
pdfimage "github.com/raff/pdfreader/image"
|
||||||
"github.com/raff/pdfreader/pdfread"
|
"github.com/raff/pdfreader/pdfread"
|
||||||
|
"golang.org/x/image/font"
|
||||||
|
"golang.org/x/image/font/gofont/gomonobold"
|
||||||
"golang.org/x/image/tiff"
|
"golang.org/x/image/tiff"
|
||||||
_ "golang.org/x/image/webp"
|
_ "golang.org/x/image/webp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
Id int
|
Id int
|
||||||
Part int
|
Part int
|
||||||
Data *ImageData
|
Raw image.Image
|
||||||
Width int
|
Data *ImageData
|
||||||
Height int
|
Width int
|
||||||
IsCover bool
|
Height int
|
||||||
NeedSpace bool
|
IsCover bool
|
||||||
Path string
|
DoublePage bool
|
||||||
Name string
|
Path string
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Image) Key(prefix string) string {
|
||||||
|
return fmt.Sprintf("%s_%d_p%d", prefix, i.Id, i.Part)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Image) SpaceKey(prefix string) string {
|
||||||
|
return fmt.Sprintf("%s_%d_sp", prefix, i.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Image) TextPath() string {
|
||||||
|
return fmt.Sprintf("Text/%d_p%d.xhtml", i.Id, i.Part)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Image) ImgPath() string {
|
||||||
|
return fmt.Sprintf("Images/%d_p%d.jpg", i.Id, i.Part)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Image) ImgStyle(viewWidth, viewHeight int, manga bool) string {
|
||||||
|
marginW, marginH := float64(viewWidth-i.Width)/2, float64(viewHeight-i.Height)/2
|
||||||
|
left, top := marginW*100/float64(viewWidth), marginH*100/float64(viewHeight)
|
||||||
|
var align string
|
||||||
|
switch i.Part {
|
||||||
|
case 0:
|
||||||
|
align = fmt.Sprintf("left:%.2f%%", left)
|
||||||
|
case 1:
|
||||||
|
if manga {
|
||||||
|
align = "left:0"
|
||||||
|
} else {
|
||||||
|
align = "right:0"
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if manga {
|
||||||
|
align = "right:0"
|
||||||
|
} else {
|
||||||
|
align = "left:0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"width:%dpx; height:%dpx; top:%.2f%%; %s;",
|
||||||
|
i.Width,
|
||||||
|
i.Height,
|
||||||
|
top,
|
||||||
|
align,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Image) SpacePath() string {
|
||||||
|
return fmt.Sprintf("Text/%d_sp.xhtml", i.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
type imageTask struct {
|
type imageTask struct {
|
||||||
@ -130,15 +186,9 @@ func (e *ePub) LoadImages() ([]*Image, error) {
|
|||||||
for img := range imageInput {
|
for img := range imageInput {
|
||||||
img.Reader.Close()
|
img.Reader.Close()
|
||||||
images = append(images, &Image{
|
images = append(images, &Image{
|
||||||
Id: img.Id,
|
Id: img.Id,
|
||||||
Part: 0,
|
Path: img.Path,
|
||||||
Data: nil,
|
Name: img.Name,
|
||||||
Width: 0,
|
|
||||||
Height: 0,
|
|
||||||
IsCover: false,
|
|
||||||
NeedSpace: false, // NeedSpace reajust during parts computation
|
|
||||||
Path: img.Path,
|
|
||||||
Name: img.Name,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +198,7 @@ func (e *ePub) LoadImages() ([]*Image, error) {
|
|||||||
imageOutput := make(chan *Image)
|
imageOutput := make(chan *Image)
|
||||||
|
|
||||||
// processing
|
// processing
|
||||||
bar := NewBar(imageCount, "Processing", 1, 2)
|
bar := NewBar(e.Quiet, imageCount, "Processing", 1, 2)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
|
|
||||||
for i := 0; i < e.ImageOptions.Workers; i++ {
|
for i := 0; i < e.ImageOptions.Workers; i++ {
|
||||||
@ -179,16 +229,24 @@ func (e *ePub) LoadImages() ([]*Image, error) {
|
|||||||
dst := image.NewGray(g.Bounds(src.Bounds()))
|
dst := image.NewGray(g.Bounds(src.Bounds()))
|
||||||
g.Draw(dst, src)
|
g.Draw(dst, src)
|
||||||
|
|
||||||
|
var raw image.Image
|
||||||
|
if img.Id == 0 {
|
||||||
|
raw = dst
|
||||||
|
}
|
||||||
|
|
||||||
imageOutput <- &Image{
|
imageOutput <- &Image{
|
||||||
Id: img.Id,
|
Id: img.Id,
|
||||||
Part: 0,
|
Part: 0,
|
||||||
Data: newImageData(img.Id, 0, dst, e.ImageOptions.Quality),
|
Raw: raw,
|
||||||
Width: dst.Bounds().Dx(),
|
Data: newImageData(img.Id, 0, dst, e.ImageOptions.Quality),
|
||||||
Height: dst.Bounds().Dy(),
|
Width: dst.Bounds().Dx(),
|
||||||
IsCover: img.Id == 0,
|
Height: dst.Bounds().Dy(),
|
||||||
NeedSpace: false,
|
IsCover: img.Id == 0,
|
||||||
Path: img.Path,
|
DoublePage: src.Bounds().Dx() > src.Bounds().Dy() &&
|
||||||
Name: img.Name,
|
src.Bounds().Dx() > e.ImageOptions.ViewHeight &&
|
||||||
|
src.Bounds().Dy() > e.ImageOptions.ViewWidth,
|
||||||
|
Path: img.Path,
|
||||||
|
Name: img.Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto split double page
|
// Auto split double page
|
||||||
@ -204,16 +262,17 @@ func (e *ePub) LoadImages() ([]*Image, error) {
|
|||||||
part := i + 1
|
part := i + 1
|
||||||
dst := image.NewGray(g.Bounds(src.Bounds()))
|
dst := image.NewGray(g.Bounds(src.Bounds()))
|
||||||
g.Draw(dst, src)
|
g.Draw(dst, src)
|
||||||
|
|
||||||
imageOutput <- &Image{
|
imageOutput <- &Image{
|
||||||
Id: img.Id,
|
Id: img.Id,
|
||||||
Part: part,
|
Part: part,
|
||||||
Data: newImageData(img.Id, part, dst, e.ImageOptions.Quality),
|
Data: newImageData(img.Id, part, dst, e.ImageOptions.Quality),
|
||||||
Width: dst.Bounds().Dx(),
|
Width: dst.Bounds().Dx(),
|
||||||
Height: dst.Bounds().Dy(),
|
Height: dst.Bounds().Dy(),
|
||||||
IsCover: false,
|
IsCover: false,
|
||||||
NeedSpace: false, // NeedSpace reajust during parts computation
|
DoublePage: false,
|
||||||
Path: img.Path,
|
Path: img.Path,
|
||||||
Name: img.Name,
|
Name: img.Name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,3 +518,63 @@ func loadPdf(input string) (int, chan *imageTask, error) {
|
|||||||
|
|
||||||
return nbPages, output, nil
|
return nbPages, output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *ePub) createTitleImageDate(title string, img *Image, currentPart, totalPart int) *ImageData {
|
||||||
|
// Create a blur version of the cover
|
||||||
|
g := gift.New(gift.GaussianBlur(8))
|
||||||
|
dst := image.NewGray(g.Bounds(img.Raw.Bounds()))
|
||||||
|
g.Draw(dst, img.Raw)
|
||||||
|
|
||||||
|
// Calculate size of title
|
||||||
|
f, _ := truetype.Parse(gomonobold.TTF)
|
||||||
|
borderSize := 4
|
||||||
|
var fontSize, textWidth, textHeight int
|
||||||
|
for fontSize = 64; fontSize >= 12; fontSize -= 1 {
|
||||||
|
face := truetype.NewFace(f, &truetype.Options{Size: float64(fontSize), DPI: 72})
|
||||||
|
textWidth = font.MeasureString(face, title).Ceil()
|
||||||
|
textHeight = face.Metrics().Ascent.Ceil() + face.Metrics().Descent.Ceil()
|
||||||
|
if textWidth+2*borderSize < img.Width && 3*textHeight+2*borderSize < img.Height {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw rectangle in the middle of the image
|
||||||
|
textPosStart := img.Height/2 - textHeight/2
|
||||||
|
textPosEnd := img.Height/2 + textHeight/2
|
||||||
|
marginSize := fontSize
|
||||||
|
borderArea := image.Rect(0, textPosStart-borderSize-marginSize, img.Width, textPosEnd+borderSize+marginSize)
|
||||||
|
textArea := image.Rect(borderSize, textPosStart-marginSize, img.Width-borderSize, textPosEnd+marginSize)
|
||||||
|
|
||||||
|
draw.Draw(
|
||||||
|
dst,
|
||||||
|
borderArea,
|
||||||
|
image.Black,
|
||||||
|
image.Point{},
|
||||||
|
draw.Over,
|
||||||
|
)
|
||||||
|
|
||||||
|
draw.Draw(
|
||||||
|
dst,
|
||||||
|
textArea,
|
||||||
|
image.White,
|
||||||
|
image.Point{},
|
||||||
|
draw.Over,
|
||||||
|
)
|
||||||
|
|
||||||
|
// Draw text
|
||||||
|
c := freetype.NewContext()
|
||||||
|
c.SetDPI(72)
|
||||||
|
c.SetFontSize(float64(fontSize))
|
||||||
|
c.SetFont(f)
|
||||||
|
c.SetClip(textArea)
|
||||||
|
c.SetDst(dst)
|
||||||
|
c.SetSrc(image.Black)
|
||||||
|
|
||||||
|
textLeft := img.Width/2 - textWidth/2
|
||||||
|
if textLeft < borderSize {
|
||||||
|
textLeft = borderSize
|
||||||
|
}
|
||||||
|
c.DrawString(title, freetype.Pt(textLeft, img.Height/2+textHeight/4))
|
||||||
|
|
||||||
|
return newData("OEBPS/Images/title.jpg", dst, e.Quality)
|
||||||
|
}
|
@ -7,7 +7,10 @@ import (
|
|||||||
"github.com/schollz/progressbar/v3"
|
"github.com/schollz/progressbar/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBar(max int, description string, currentJob, totalJob int) *progressbar.ProgressBar {
|
func NewBar(quiet bool, max int, description string, currentJob, totalJob int) *progressbar.ProgressBar {
|
||||||
|
if quiet {
|
||||||
|
return progressbar.DefaultSilent(int64(max))
|
||||||
|
}
|
||||||
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(totalJob)))
|
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(totalJob)))
|
||||||
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
||||||
return progressbar.NewOptions(max,
|
return progressbar.NewOptions(max,
|
18
internal/epub/epub_templates.go
Normal file
18
internal/epub/epub_templates.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package epub
|
||||||
|
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
//go:embed "templates/epub_templates_container.xml.tmpl"
|
||||||
|
var containerTmpl string
|
||||||
|
|
||||||
|
//go:embed "templates/epub_templates_applebooks.xml.tmpl"
|
||||||
|
var appleBooksTmpl string
|
||||||
|
|
||||||
|
//go:embed "templates/epub_templates_style.css.tmpl"
|
||||||
|
var styleTmpl string
|
||||||
|
|
||||||
|
//go:embed "templates/epub_templates_text.xhtml.tmpl"
|
||||||
|
var textTmpl string
|
||||||
|
|
||||||
|
//go:embed "templates/epub_templates_blank.xhtml.tmpl"
|
||||||
|
var blankTmpl string
|
65
internal/epub/epub_toc.go
Normal file
65
internal/epub/epub_toc.go
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package epub
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/beevik/etree"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e *ePub) getToc(title string, images []*Image) string {
|
||||||
|
doc := etree.NewDocument()
|
||||||
|
doc.CreateProcInst("xml", `version="1.0" encoding="UTF-8"`)
|
||||||
|
doc.CreateDirective("DOCTYPE html")
|
||||||
|
|
||||||
|
html := doc.CreateElement("html")
|
||||||
|
html.CreateAttr("xmlns", "http://www.w3.org/1999/xhtml")
|
||||||
|
html.CreateAttr("xmlns:epub", "http://www.idpf.org/2007/ops")
|
||||||
|
|
||||||
|
html.CreateElement("head").CreateElement("title").CreateText(title)
|
||||||
|
body := html.CreateElement("body")
|
||||||
|
nav := body.CreateElement("nav")
|
||||||
|
nav.CreateAttr("epub:type", "toc")
|
||||||
|
nav.CreateAttr("id", "toc")
|
||||||
|
nav.CreateElement("h2").CreateText(title)
|
||||||
|
|
||||||
|
ol := etree.NewElement("ol")
|
||||||
|
paths := map[string]*etree.Element{".": ol}
|
||||||
|
for _, img := range images {
|
||||||
|
currentPath := "."
|
||||||
|
for _, path := range strings.Split(img.Path, string(filepath.Separator)) {
|
||||||
|
parentPath := currentPath
|
||||||
|
currentPath = filepath.Join(currentPath, path)
|
||||||
|
if _, ok := paths[currentPath]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t := paths[parentPath].CreateElement("li")
|
||||||
|
link := t.CreateElement("a")
|
||||||
|
link.CreateAttr("href", img.TextPath())
|
||||||
|
link.CreateText(path)
|
||||||
|
paths[currentPath] = t.CreateElement("ol")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ol.ChildElements()) == 1 && e.StripFirstDirectoryFromToc {
|
||||||
|
ol = ol.FindElement("/li/ol")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range ol.FindElements("//ol") {
|
||||||
|
if len(v.ChildElements()) == 0 {
|
||||||
|
v.Parent().RemoveChild(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
beginning := etree.NewElement("li")
|
||||||
|
beginningLink := beginning.CreateElement("a")
|
||||||
|
beginningLink.CreateAttr("href", "Text/title.xhtml")
|
||||||
|
beginningLink.CreateText(title)
|
||||||
|
ol.InsertChildAt(0, beginning)
|
||||||
|
|
||||||
|
nav.AddChild(ol)
|
||||||
|
|
||||||
|
doc.Indent(2)
|
||||||
|
r, _ := doc.WriteToString()
|
||||||
|
return r
|
||||||
|
}
|
@ -51,3 +51,20 @@ func (n *Node) toString(indent string) string {
|
|||||||
}
|
}
|
||||||
return r.String()
|
return r.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *ePub) getTree(images []*Image, skip_files bool) string {
|
||||||
|
t := NewTree()
|
||||||
|
for _, img := range images {
|
||||||
|
if skip_files {
|
||||||
|
t.Add(img.Path)
|
||||||
|
} else {
|
||||||
|
t.Add(filepath.Join(img.Path, img.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c := t.Root()
|
||||||
|
if skip_files && e.StripFirstDirectoryFromToc && len(c.Children) == 1 {
|
||||||
|
c = c.Children[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.toString("")
|
||||||
|
}
|
@ -1,33 +0,0 @@
|
|||||||
package epub
|
|
||||||
|
|
||||||
import _ "embed"
|
|
||||||
|
|
||||||
//go:embed "templates/container.xml.tmpl"
|
|
||||||
var containerTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/content.opf.tmpl"
|
|
||||||
var contentTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/toc.ncx.tmpl"
|
|
||||||
var tocTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/nav.xhtml.tmpl"
|
|
||||||
var navTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/style.css.tmpl"
|
|
||||||
var styleTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/panelview.css.tmpl"
|
|
||||||
var panelViewTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/part.xhtml.tmpl"
|
|
||||||
var partTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/text.xhtml.tmpl"
|
|
||||||
var textTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/textnopanel.xhtml.tmpl"
|
|
||||||
var textNoPanelTmpl string
|
|
||||||
|
|
||||||
//go:embed "templates/blank.xhtml.tmpl"
|
|
||||||
var blankTmpl string
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
|
|
||||||
<rootfiles>
|
|
||||||
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
|
|
||||||
</rootfiles>
|
|
||||||
</container>
|
|
@ -1,57 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<package version="3.0" unique-identifier="BookID" xmlns="http://www.idpf.org/2007/opf">
|
|
||||||
{{ $info := .Info }}
|
|
||||||
<metadata xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
|
||||||
<dc:title>{{ .Title }}</dc:title>
|
|
||||||
<dc:language>en-US</dc:language>
|
|
||||||
<dc:identifier id="BookID">urn:uuid:{{ $info.UID }}</dc:identifier>
|
|
||||||
<dc:contributor id="contributor">{{ $info.Publisher }}</dc:contributor>
|
|
||||||
<dc:publisher>{{ $info.Publisher }}</dc:publisher>
|
|
||||||
<dc:date>{{ $info.UpdatedAt }}</dc:date>
|
|
||||||
<dc:creator>{{ $info.Author }}</dc:creator>
|
|
||||||
<meta property="dcterms:modified">{{ $info.UpdatedAt }}</meta>
|
|
||||||
<meta name="original-resolution" content="{{ $info.ViewWidth }}x{{ $info.ViewHeight }}"/>
|
|
||||||
<meta name="book-type" content="comic"/>
|
|
||||||
<meta name="primary-writing-mode" content="horizontal-{{ if $info.Manga }}rl{{ else }}lr{{ end }}"/>
|
|
||||||
<meta property="rendition:layout">pre-paginated</meta>
|
|
||||||
<meta property="rendition:orientation">portrait</meta>
|
|
||||||
<meta name="orientation-lock" content="portrait"/>
|
|
||||||
{{ if eq $info.AddPanelView true }}
|
|
||||||
<meta name="region-mag" content="true"/>
|
|
||||||
{{ end }}
|
|
||||||
{{ if gt .Total 1 }}
|
|
||||||
<meta name="calibre:series" content="{{ $info.Title }}"/>
|
|
||||||
<meta name="calibre:series_index" content="{{ .Part }}"/>
|
|
||||||
{{ end }}
|
|
||||||
</metadata>
|
|
||||||
<manifest>
|
|
||||||
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
|
|
||||||
<item id="nav" href="nav.xhtml" properties="nav" media-type="application/xhtml+xml"/>
|
|
||||||
<item id="style_css" href="Text/style.css" media-type="text/css"/>
|
|
||||||
{{ if eq $info.AddPanelView true }}
|
|
||||||
<item id="panelview_css" href="Text/panelview.css" media-type="text/css"/>
|
|
||||||
{{ end }}
|
|
||||||
<item id="cover" href="Images/{{ .Cover.Id }}_p{{ .Cover.Part }}.jpg" media-type="image/jpeg" properties="cover-image"/>
|
|
||||||
{{ range .Images }}
|
|
||||||
{{ if eq .IsCover false }}
|
|
||||||
<item id="img_{{ .Id }}_p{{ .Part}}" href="Images/{{ .Id }}_p{{ .Part}}.jpg" media-type="image/jpeg"/>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
<item id="page_part" href="Text/part.xhtml" media-type="application/xhtml+xml"/>
|
|
||||||
{{ range .Images }}
|
|
||||||
<item id="page_{{ .Id }}_p{{ .Part}}" href="Text/{{ .Id }}_p{{ .Part}}.xhtml" media-type="application/xhtml+xml"/>
|
|
||||||
{{ if eq .NeedSpace true }}
|
|
||||||
<item id="page_{{ .Id }}_sp" href="Text/{{ .Id }}_sp.xhtml" media-type="application/xhtml+xml"/>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</manifest>
|
|
||||||
<spine toc="ncx" page-progression-direction="{{ if $info.Manga }}rtl{{ else }}ltr{{ end }}">
|
|
||||||
<itemref idref="page_part" linear="yes"/>
|
|
||||||
{{ range .Images }}
|
|
||||||
{{ if eq .NeedSpace true }}
|
|
||||||
<itemref idref="page_{{ .Id }}_sp" linear="yes"/>
|
|
||||||
{{ end }}
|
|
||||||
<itemref idref="page_{{ .Id }}_p{{ .Part }}" linear="yes"/>
|
|
||||||
{{ end }}
|
|
||||||
</spine>
|
|
||||||
</package>
|
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<display_options>
|
||||||
|
<platform name="*">
|
||||||
|
<option name="fixed-layout">true</option>
|
||||||
|
</platform>
|
||||||
|
</display_options>
|
@ -2,11 +2,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
||||||
<head>
|
<head>
|
||||||
<title>Page {{ .Image.Id }} Space</title>
|
<meta charset="utf-8" />
|
||||||
|
<title>{{ .Title }}</title>
|
||||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||||
<meta name="viewport" content="width={{ .Info.ViewWidth }}, height={{ .Info.ViewHeight }}"/>
|
<meta name="viewport" content="{{ .ViewPort }}"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>{{ if .Info.Manga }}←{{ else }}→{{ end }}</h1>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<container version="1.0"
|
||||||
|
xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
|
||||||
|
<rootfiles>
|
||||||
|
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
|
||||||
|
</rootfiles>
|
||||||
|
</container>
|
18
internal/epub/templates/epub_templates_style.css.tmpl
Normal file
18
internal/epub/templates/epub_templates_style.css.tmpl
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
body {
|
||||||
|
color: #000;
|
||||||
|
background: #FFF;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: {{ .PageWidth }}px;
|
||||||
|
height: {{ .PageHeight }}px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
position: absolute;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
z-index:0;
|
||||||
|
}
|
@ -2,14 +2,14 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
||||||
<head>
|
<head>
|
||||||
<title>Part {{ .Part }}</title>
|
<meta charset="utf-8" />
|
||||||
|
<title>{{ .Title }}</title>
|
||||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||||
<meta name="viewport" content="width={{ .Info.ViewWidth }}, height={{ .Info.ViewHeight }}"/>
|
<meta name="viewport" content="{{ .ViewPort }}"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>{{ .Info.Title }}</h1>
|
<div>
|
||||||
{{ if gt .Total 1 }}
|
<img src="../{{ .ImagePath }}" alt="{{ .Title }}" style="{{ .ImageStyle }}"/>
|
||||||
<h1>Part {{ .Part }} / {{ .Total }}</h1>
|
</div>
|
||||||
{{ end }}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
|
||||||
<head>
|
|
||||||
<title>{{ .Title }}</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav epub:type="toc" id="toc">
|
|
||||||
<h2>Table of content</h2>
|
|
||||||
<ol>
|
|
||||||
<li><a href="Text/part.xhtml">{{ .Title }}</a></li>
|
|
||||||
{{ .TOC }}
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,103 +0,0 @@
|
|||||||
a.app-amzn-magnify {
|
|
||||||
display: inline-block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV {
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-T {
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-B {
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-L {
|
|
||||||
left: 0;
|
|
||||||
width: 49.5%;
|
|
||||||
height: 100%;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-R {
|
|
||||||
right: 0;
|
|
||||||
width: 49.5%;
|
|
||||||
height: 100%;
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-TL {
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 49.5%;
|
|
||||||
height: 50%;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-TR {
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
width: 49.5%;
|
|
||||||
height: 50%;
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-BL {
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 49.5%;
|
|
||||||
height: 50%;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#PV-BR {
|
|
||||||
bottom: 0;
|
|
||||||
right: 0;
|
|
||||||
width: 49.5%;
|
|
||||||
height: 50%;
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.PV-P {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
top: 0;
|
|
||||||
position: absolute;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#PV-TL-P img {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#PV-TR-P img {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#PV-BL-P img {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#PV-BR-P img {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
@charset "UTF-8";
|
|
||||||
|
|
||||||
html {
|
|
||||||
color: #000;
|
|
||||||
background: #FFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-size: 16px;
|
|
||||||
text-align: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
body,
|
|
||||||
div,
|
|
||||||
dl,
|
|
||||||
dt,
|
|
||||||
dd,
|
|
||||||
ul,
|
|
||||||
ol,
|
|
||||||
li,
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6,
|
|
||||||
th,
|
|
||||||
td {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
border-spacing: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldset,
|
|
||||||
img {
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
caption,
|
|
||||||
th,
|
|
||||||
var {
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
caption,
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6 {
|
|
||||||
font-size: 150%;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
sup {
|
|
||||||
vertical-align: text-top;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub {
|
|
||||||
vertical-align: text-bottom;
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
|
||||||
<head>
|
|
||||||
<title>Page {{ .Image.Id }}_p{{ .Image.Part}}</title>
|
|
||||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
|
||||||
<link href="panelview.css" type="text/css" rel="stylesheet"/>
|
|
||||||
<meta name="viewport" content="width={{ .Image.Width }}, height={{ .Image.Height }}"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<img style="width:{{ .Image.Width }}px; height:{{ .Image.Height }}px" src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg"/>
|
|
||||||
</div>
|
|
||||||
<div id="PV">
|
|
||||||
<div id="PV-TL">
|
|
||||||
<a class="app-amzn-magnify" data-app-amzn-magnify='{"targetId":"PV-TL-P", "ordinal":{{ if .Manga }}2{{ else }}1{{ end }}}'></a>
|
|
||||||
</div>
|
|
||||||
<div id="PV-TR">
|
|
||||||
<a class="app-amzn-magnify" data-app-amzn-magnify='{"targetId":"PV-TR-P", "ordinal":{{ if .Manga }}1{{ else }}2{{ end }}}'></a>
|
|
||||||
</div>
|
|
||||||
<div id="PV-BL">
|
|
||||||
<a class="app-amzn-magnify" data-app-amzn-magnify='{"targetId":"PV-BL-P", "ordinal":{{ if .Manga }}4{{ else }}3{{ end }}}'></a>
|
|
||||||
</div>
|
|
||||||
<div id="PV-BR">
|
|
||||||
<a class="app-amzn-magnify" data-app-amzn-magnify='{"targetId":"PV-BR-P", "ordinal":{{ if .Manga }}3{{ else }}4{{ end }}}'></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="PV-P" id="PV-TL-P">
|
|
||||||
<img src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg" width="{{ zoom .Image.Width 1.5 }}" height="{{ zoom .Image.Height 1.5 }}"/>
|
|
||||||
</div>
|
|
||||||
<div class="PV-P" id="PV-TR-P">
|
|
||||||
<img src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg" width="{{ zoom .Image.Width 1.5 }}" height="{{ zoom .Image.Height 1.5 }}"/>
|
|
||||||
</div>
|
|
||||||
<div class="PV-P" id="PV-BL-P">
|
|
||||||
<img src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg" width="{{ zoom .Image.Width 1.5 }}" height="{{ zoom .Image.Height 1.5 }}"/>
|
|
||||||
</div>
|
|
||||||
<div class="PV-P" id="PV-BR-P">
|
|
||||||
<img src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg" width="{{ zoom .Image.Width 1.5 }}" height="{{ zoom .Image.Height 1.5 }}"/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
|
||||||
<head>
|
|
||||||
<title>Page {{ .Image.Id }}_p{{ .Image.Part}}</title>
|
|
||||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
|
||||||
<meta name="viewport" content="width={{ .Image.Width }}, height={{ .Image.Height }}"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<img style="width:{{ .Image.Width }}px; height:{{ .Image.Height }}px" src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg"/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ncx version="2005-1" xml:lang="en-US" xmlns="http://www.daisy.org/z3986/2005/ncx/">
|
|
||||||
<head>
|
|
||||||
<meta name="dtb:uid" content="urn:uuid:{{ .Info.UID }}"/>
|
|
||||||
<meta name="dtb:depth" content="1"/>
|
|
||||||
<meta name="dtb:totalPageCount" content="0"/>
|
|
||||||
<meta name="dtb:maxPageNumber" content="0"/>
|
|
||||||
<meta name="generated" content="true"/>
|
|
||||||
</head>
|
|
||||||
<docTitle><text>{{ .Title }}</text></docTitle>
|
|
||||||
<navMap>
|
|
||||||
<navPoint id="Text"><navLabel><text>{{ .Title }}</text></navLabel><content src="Text/part.xhtml"/></navPoint>
|
|
||||||
</navMap>
|
|
||||||
</ncx>
|
|
@ -1,22 +0,0 @@
|
|||||||
package epub
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/xml"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TocTitle struct {
|
|
||||||
XMLName xml.Name `xml:"a"`
|
|
||||||
Value string `xml:",innerxml"`
|
|
||||||
Link string `xml:"href,attr"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TocChildren struct {
|
|
||||||
XMLName xml.Name `xml:"ol"`
|
|
||||||
Tags []*TocPart
|
|
||||||
}
|
|
||||||
|
|
||||||
type TocPart struct {
|
|
||||||
XMLName xml.Name `xml:"li"`
|
|
||||||
Title TocTitle
|
|
||||||
Children *TocChildren `xml:",omitempty"`
|
|
||||||
}
|
|
12
main.go
12
main.go
@ -91,6 +91,8 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
fmt.Fprintln(os.Stderr, cmd.Options)
|
fmt.Fprintln(os.Stderr, cmd.Options)
|
||||||
|
|
||||||
profile := cmd.Options.GetProfile()
|
profile := cmd.Options.GetProfile()
|
||||||
|
perfectWidth, perfectHeight := profile.PerfectDim()
|
||||||
|
|
||||||
if err := epub.NewEpub(&epub.EpubOptions{
|
if err := epub.NewEpub(&epub.EpubOptions{
|
||||||
Input: cmd.Options.Input,
|
Input: cmd.Options.Input,
|
||||||
Output: cmd.Options.Output,
|
Output: cmd.Options.Output,
|
||||||
@ -98,12 +100,10 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
Title: cmd.Options.Title,
|
Title: cmd.Options.Title,
|
||||||
Author: cmd.Options.Author,
|
Author: cmd.Options.Author,
|
||||||
StripFirstDirectoryFromToc: cmd.Options.StripFirstDirectoryFromToc,
|
StripFirstDirectoryFromToc: cmd.Options.StripFirstDirectoryFromToc,
|
||||||
Dry: cmd.Options.Dry,
|
|
||||||
DryVerbose: cmd.Options.DryVerbose,
|
|
||||||
SortPathMode: cmd.Options.SortPathMode,
|
SortPathMode: cmd.Options.SortPathMode,
|
||||||
ImageOptions: &epub.ImageOptions{
|
ImageOptions: &epub.ImageOptions{
|
||||||
ViewWidth: profile.Width,
|
ViewWidth: perfectWidth,
|
||||||
ViewHeight: profile.Height,
|
ViewHeight: perfectHeight,
|
||||||
Quality: cmd.Options.Quality,
|
Quality: cmd.Options.Quality,
|
||||||
Crop: cmd.Options.Crop,
|
Crop: cmd.Options.Crop,
|
||||||
Brightness: cmd.Options.Brightness,
|
Brightness: cmd.Options.Brightness,
|
||||||
@ -113,9 +113,11 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
NoBlankPage: cmd.Options.NoBlankPage,
|
NoBlankPage: cmd.Options.NoBlankPage,
|
||||||
Manga: cmd.Options.Manga,
|
Manga: cmd.Options.Manga,
|
||||||
HasCover: cmd.Options.HasCover,
|
HasCover: cmd.Options.HasCover,
|
||||||
AddPanelView: cmd.Options.AddPanelView,
|
|
||||||
Workers: cmd.Options.Workers,
|
Workers: cmd.Options.Workers,
|
||||||
},
|
},
|
||||||
|
Dry: cmd.Options.Dry,
|
||||||
|
DryVerbose: cmd.Options.DryVerbose,
|
||||||
|
Quiet: cmd.Options.Quiet,
|
||||||
}).Write(); err != nil {
|
}).Write(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user