Skip to content

Commit

Permalink
🚩 Disable PDF analysis for now, because cross-compiling cgo (fitz has…
Browse files Browse the repository at this point in the history
… cgo) is hard...
  • Loading branch information
ewen-lbh committed Apr 16, 2024
1 parent 740e3c5 commit b8a1418
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/PuerkitoBio/goquery v1.9.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/gen2brain/go-fitz v1.23.7
github.com/hullerob/go.farbfeld v0.0.0-20181222022525-3661193c725f
github.com/jbuchbinder/gopnm v0.0.0-20220507095634-e31f54490ce0
github.com/k3a/html2text v1.2.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ 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/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gen2brain/go-fitz v1.23.7 h1:HPhzEVzmOINvCKqQgB/DwMzYh4ArIgy3tMwq1eJTcbg=
github.com/gen2brain/go-fitz v1.23.7/go.mod h1:HU04vc+RisUh/kvEd2pB0LAxmK1oyXdN4ftyshUr9rQ=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
Expand Down
5 changes: 4 additions & 1 deletion media.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"strings"

"github.com/gabriel-vasile/mimetype"
"github.com/gen2brain/go-fitz"
// "github.com/gen2brain/go-fitz" // FIXME requires cgo, which goreleaser has a hard time with
"github.com/lafriks/go-svg"
"github.com/metal3d/go-slugify"
recurcopy "github.com/plus3it/gorecurcopy"
Expand Down Expand Up @@ -292,6 +292,8 @@ func AnalyzeAudio(file *os.File) uint {

// AnalyzePDF returns an ImageDimensions struct for the first page of the PDF file at filename. It also returns the number of pages.
func AnalyzePDF(filename string) (dimensions ImageDimensions, pagesCount uint, err error) {
return ImageDimensions{}, 0, errors.New("PDF analysis is disabled")
/* fitz requires cgo, which goreleaser has a hard time with.
document, err := fitz.New(filename)
if err != nil {
return dimensions, pagesCount, fmt.Errorf("while opening PDF: %w", err)
Expand All @@ -312,6 +314,7 @@ func AnalyzePDF(filename string) (dimensions ImageDimensions, pagesCount uint, e
Height: int(height),
AspectRatio: float32(width) / float32(height),
}, uint(document.NumPage()), nil
*/
}

// AnalyzeVideo returns an ImageDimensions struct with the video's height, width and aspect ratio and a duration in seconds.
Expand Down
4 changes: 4 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,7 @@ func ensureHttpPrefix(url string) string {
func debugging() bool {
return os.Getenv("DEBUG") == "1" || os.Getenv("ORTFO_DEBUG") == "1" || os.Getenv("ORTFODB_DEBUG") == "1"
}

func cgoEnabled() bool {
return os.Getenv("CGO_ENABLED") == "1"
}

0 comments on commit b8a1418

Please sign in to comment.