mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-06-27 23:59:55 +02:00
update to go1.22
This commit is contained in:
parent
1ff7912b0f
commit
ab62692ce6
4
go.mod
4
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/celogeek/go-comic-converter/v2
|
||||
|
||||
go 1.21
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/beevik/etree v1.3.0
|
||||
@ -10,7 +10,7 @@ require (
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
github.com/nwaples/rardecode/v2 v2.0.0-beta.2
|
||||
github.com/raff/pdfreader v0.0.0-20220308062436-033e8ac577f0
|
||||
github.com/schollz/progressbar/v3 v3.14.1
|
||||
github.com/schollz/progressbar/v3 v3.14.2
|
||||
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e
|
||||
golang.org/x/image v0.15.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
|
7
go.sum
7
go.sum
@ -29,11 +29,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/raff/pdfreader v0.0.0-20220308062436-033e8ac577f0 h1:fuFvfwIc+cpySYurvDNTs5LIHXP9Cj3reVRplj9Whv4=
|
||||
github.com/raff/pdfreader v0.0.0-20220308062436-033e8ac577f0/go.mod h1:Ql3QqeGiYGlPOtYz+F/L7J27spqDcdH9LhDHOrrdsD4=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/schollz/progressbar/v3 v3.14.1 h1:VD+MJPCr4s3wdhTc7OEJ/Z3dAeBzJ7yKH/P4lC5yRTI=
|
||||
github.com/schollz/progressbar/v3 v3.14.1/go.mod h1:Zc9xXneTzWXF81TGoqL71u0sBPjULtEHYtj/WVgVy8E=
|
||||
github.com/schollz/progressbar/v3 v3.14.2 h1:EducH6uNLIWsr560zSV1KrTeUb/wZGAHqyMFIEa99ks=
|
||||
github.com/schollz/progressbar/v3 v3.14.2/go.mod h1:aQAZQnhF4JGFtRJiw/eobaXpsqpVQAftEQ+hLGXaRc4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
@ -45,10 +44,8 @@ golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
|
||||
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
@ -18,21 +18,21 @@ type autocontrast struct {
|
||||
|
||||
// compute the color number between 0 and 1 that hold half of the pixel
|
||||
func (f *autocontrast) mean(src image.Image) float32 {
|
||||
bucket := map[uint32]int{}
|
||||
bucket := map[int]int{}
|
||||
for x := src.Bounds().Min.X; x < src.Bounds().Max.X; x++ {
|
||||
for y := src.Bounds().Min.Y; y < src.Bounds().Max.Y; y++ {
|
||||
v, _, _, _ := color.GrayModel.Convert(src.At(x, y)).RGBA()
|
||||
bucket[v]++
|
||||
bucket[int(v)]++
|
||||
}
|
||||
}
|
||||
|
||||
// calculate color idx
|
||||
var colorIdx uint32
|
||||
var colorIdx int
|
||||
{
|
||||
// limit to half of the pixel
|
||||
limit := src.Bounds().Dx() * src.Bounds().Dy() / 2
|
||||
// loop on all color from 0 to 65536
|
||||
for colorIdx = 0; colorIdx < 1<<16; colorIdx++ {
|
||||
for colorIdx := range 1 << 16 {
|
||||
if limit-bucket[colorIdx] < 0 {
|
||||
break
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
|
||||
if e.Image.Format == "png" {
|
||||
wr = 100
|
||||
}
|
||||
for i := 0; i < e.WorkersRatio(wr); i++ {
|
||||
for range e.WorkersRatio(wr) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
@ -141,7 +141,7 @@ func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *task, err
|
||||
// read in parallel and get an image
|
||||
output = make(chan *task, e.Workers)
|
||||
wg := &sync.WaitGroup{}
|
||||
for j := 0; j < e.WorkersRatio(50); j++ {
|
||||
for range e.WorkersRatio(50) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -233,7 +233,7 @@ func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *task, err
|
||||
|
||||
output = make(chan *task, e.Workers)
|
||||
wg := &sync.WaitGroup{}
|
||||
for j := 0; j < e.WorkersRatio(50); j++ {
|
||||
for range e.WorkersRatio(50) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -352,7 +352,7 @@ func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *task, err
|
||||
// send file to the queue
|
||||
output = make(chan *task, e.Workers)
|
||||
wg := &sync.WaitGroup{}
|
||||
for j := 0; j < e.WorkersRatio(50); j++ {
|
||||
for range e.WorkersRatio(50) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -403,7 +403,7 @@ func (e *EPUBImageProcessor) loadPdf() (totalImages int, output chan *task, err
|
||||
go func() {
|
||||
defer close(output)
|
||||
defer pdf.Close()
|
||||
for i := 0; i < totalImages; i++ {
|
||||
for i := range totalImages {
|
||||
var img image.Image
|
||||
var err error
|
||||
if !e.Dry {
|
||||
|
@ -73,7 +73,7 @@ func compareParts(a, b []part) float64 {
|
||||
if m > len(b) {
|
||||
m = len(b)
|
||||
}
|
||||
for i := 0; i < m; i++ {
|
||||
for i := range m {
|
||||
c := a[i].compare(b[i])
|
||||
if c != 0 {
|
||||
return c
|
||||
|
Loading…
x
Reference in New Issue
Block a user