Skip to content

Commit 0b5bf41

Browse files
Eric CookEric Cook
Eric Cook
authored and
Eric Cook
committed
Initial commit
0 parents  commit 0b5bf41

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

glide.lock

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package: keybase/ecook/thumbnails
2+
import:
3+
- package: github.com/mattn/go-sqlite3
4+
version: ^1.9.0

main.go

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package main
2+
3+
import (
4+
"database/sql"
5+
"fmt"
6+
_ "github.com/mattn/go-sqlite3"
7+
"image"
8+
"image/png"
9+
"os"
10+
)
11+
12+
type Thumnails struct {
13+
width int
14+
height int
15+
bitspercomponent int
16+
bitsperpixel int
17+
bytesperrow int
18+
bitmapdata_location int
19+
bitmapdata_length int
20+
}
21+
22+
func main() {
23+
println("starting")
24+
//echo $TMPDIR
25+
input := fmt.Sprintf("%s../C/com.apple.QuickLook.thumbnailcache", os.Args[1])
26+
println(input)
27+
28+
dbLocation := fmt.Sprintf("%s/index.sqlite", input)
29+
println(dbLocation)
30+
db, err := sql.Open("sqlite3", dbLocation)
31+
if err != nil {
32+
panic(err)
33+
}
34+
35+
rows, err := db.Query("select * from thumnails limit 1;")
36+
if err != nil {
37+
panic(err)
38+
}
39+
40+
thumbnailData := &Thumnails{}
41+
for rows.Next() {
42+
err = rows.Scan(thumbnailData)
43+
if err != nil {
44+
panic(err)
45+
}
46+
fmt.Println(string(thumbnailData.width))
47+
}
48+
defer rows.Close()
49+
50+
dataFile := fmt.Sprintf("%s/thumbnails.data", input)
51+
52+
println(dataFile)
53+
f, err := os.Open(dataFile)
54+
if err != nil {
55+
panic(err)
56+
}
57+
defer f.Close()
58+
59+
dataLocation := int64(6583848)
60+
//ret, err := f.Seek(dataLocation, 0)
61+
//if err != nil {
62+
// panic(err)
63+
//}
64+
//println(ret)
65+
66+
const dataLength = 4096
67+
buf := make([]byte, dataLength)
68+
fileContents, err := f.ReadAt(buf, dataLocation)
69+
if err != nil {
70+
panic(err)
71+
}
72+
73+
println(fileContents)
74+
75+
println(len(buf))
76+
77+
println(string(buf[:dataLength]))
78+
79+
bytesperrow := 128
80+
bitsperpixel := 32
81+
bitspercomponent := 8
82+
83+
width := bytesperrow / (bitsperpixel / bitspercomponent)
84+
height := 32
85+
86+
img := &image.RGBA{Pix: buf, Stride: bytesperrow, Rect: image.Rect(0, 0, width, height)}
87+
88+
out, _ := os.OpenFile("out.png", os.O_WRONLY|os.O_CREATE, 0600)
89+
defer out.Close()
90+
png.Encode(out, img)
91+
}

0 commit comments

Comments
 (0)