This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-09-22 14:23:02

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Squeak code to get project thumbnail?

Does anybody know the Squeak code to get a project thumbnail?


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#2 2012-09-22 14:26:31

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Squeak code to get project thumbnail?

Neop.


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#3 2012-09-22 14:30:38

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Squeak code to get project thumbnail?

| filename f data s version dict thumb |
filename := 'whatever'.

f := FileStream readOnlyFileNamedOrNil: filename.
data := f binary contentsOfEntireFile.
s := ReadStream on: data.
version := ObjStream scratchFileVersionFrom: (s next: 10) asString.
(version = 1) | (version = 2)
    ifTrue: [
        s skip: 4.
        dict := ObjStream new readObjFrom: s showProgress: false.
        thumb := dict at: 'thumbnail']
    ifFalse: [thumb := nil].

"do something with thumb"
thumb display

Last edited by nXIII (2012-09-22 14:31:08)


nXIII

Offline

 

#4 2012-09-22 14:34:24

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Squeak code to get project thumbnail?

Modshare?  tongue


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#5 2012-09-22 14:36:13

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Squeak code to get project thumbnail?

I can do it in Python...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6 2012-09-22 14:36:42

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Squeak code to get project thumbnail?

I can do it in JavaScript.  tongue

Last edited by MathWizz (2012-09-22 14:36:48)


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#7 2012-09-22 14:59:33

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Squeak code to get project thumbnail?

MathWizz wrote:

I can do it in JavaScript.  tongue

My code looks nicer.  tongue

Code:

import kurt
kurt.ScratchProjectFile("project.sb").info["thumbnail"].save("thumbnail.png")

Last edited by blob8108 (2012-09-22 15:19:57)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#8 2012-09-22 15:02:44

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak code to get project thumbnail?

Does anybody know it in PHP? (i.e. to get it as a PNG or something?)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#9 2012-09-22 15:19:36

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Squeak code to get project thumbnail?

jvvg wrote:

Does anybody know it in PHP? (i.e. to get it as a PNG or something?)

I don't think anyone's written a .sb parser in PHP. If your host supports Python, you could always execute a Python script using PHP's "exec".  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#10 2012-09-22 15:20:38

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Squeak code to get project thumbnail?

I believe that JSO posted about this a while back, but I can't seem to find it. I'll keep looking.  big_smile

Offline

 

#11 2012-09-22 15:31:32

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Squeak code to get project thumbnail?

I wrote one once upon a time. I could quickly translate my JavaScript one to PHP...


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#12 2012-09-22 20:29:03

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Squeak code to get project thumbnail?

Here. It accepts a (local) file path in the "filename" request argument and outputs a thumbnail PNG.


nXIII

Offline

 

#13 2012-09-22 21:08:20

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak code to get project thumbnail?

nXIII wrote:

Here. It accepts a (local) file path in the "filename" request argument and outputs a thumbnail PNG.

Thanks. Testing it out.  smile


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#14 2012-09-22 21:34:06

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak code to get project thumbnail?

Thank you very much, nXIII. The code works.  smile

@MathWizz: yep. It's part of the Insanity/Bingo direct uploader.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

Board footer