Skip to content

Commit e63b810

Browse files
committed
fix: fix app icon extraction
1 parent 6b7a251 commit e63b810

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

internal/ipa/ipa.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package ipa
33
import (
44
"archive/zip"
55
"errors"
6-
"fmt"
76
"image"
87
"image/png"
98
"io"
9+
"log"
1010
"os"
1111
"path/filepath"
1212
"regexp"
@@ -149,7 +149,7 @@ func Parse(readerAt io.ReaderAt, size int64) (*IPA, error) {
149149
if img, err := parseIconAssets(assetFile); err == nil {
150150
app.icon = img
151151
} else {
152-
fmt.Println(err)
152+
log.Println(err)
153153
}
154154
}
155155

@@ -244,6 +244,8 @@ func parseIconAssets(assetFile *zip.File) (image.Image, error) {
244244

245245
if candidates, err := a.ImageCandidates("icon"); err == nil && len(candidates) > 0 {
246246
var best *asset.ImageCandidateInfo
247+
248+
// find not layered icon and return
247249
for i := range candidates {
248250
if strings.Contains(candidates[i].Name, "/Content") {
249251
continue
@@ -255,6 +257,13 @@ func parseIconAssets(assetFile *zip.File) (image.Image, error) {
255257
if best != nil {
256258
return best.Image, nil
257259
}
260+
261+
// find /Front/Content layered icon and return
262+
for i := range candidates {
263+
if strings.Contains(candidates[i].Name, "/Front/Content") {
264+
return candidates[i].Image, nil
265+
}
266+
}
258267
}
259268
return nil, errors.New("icon not found")
260269
}

0 commit comments

Comments
 (0)