Hi all,
I have a question for all you source code pros...
For my Scratch Resources site, I wanted thumbnails and snapshots to be generated for all sprites. The best way would be to do it with PHP, but since there's no sprite file format description released (!! Scratch team?
) I can't.
So I had the idea of using the Scratch Source code - I just built my own server with windows XP, and I am sure it can be done to make it generate images say every day, using a modified version of the Scratch source code (and some PHP but I can do that on my own
).
Once I got to that, I thought it could also work to automatically export the scripts to an image. (It's already in Scratch, But I don't want to spend opening and clicking for hours every day. Could it be done automatically when Scratch opens a sprite?)
So, this is what I wanted:
• automatic thumbnail generation when I do something like
Scratch.exe Scratchmod1.image "mysprite.sprite"
• automatic 'Export script snapshot' when I do something like
Scratch.exe Scratchmod2.image "spritewithscriptsinit.sprite"
I started to do this my self but I soon realized this is *far* beyond my capabilities/squeak knowledge...
Could some of you please help me?
Joren
Offline
As far as I'm aware, Scratch stores costumes in bitmap format embedded in .sprite files, so first goal could be achieved without even touching Scratch; you'd only have to make a php script reading it.
Last edited by filo5 (2010-01-24 15:23:24)
Offline
It sounds very doable... Would you want the script to save the images to a directory?
Offline
Hi, JSO
You can access command the command line (parameters) in Squeak using a primitive in class SystemDictionary (it's documented there). If you start looking at class ScratchFrameMorph's #startup method, you'll also find examples of how to access the command line (e.g. for the 'presentation' flag). I guess this should get you going. Then the other task would be to run Squeak "headless", i.e. without opening a window. If I remember this right, there are some flags that you can set in the .ini file for this (you'll find documentation if you google SqueakVM, or go to the Squeak.org website). Good luck!
Offline
Squeak command line options
...
-headless
Tells Squeak to run without a main window. However, for allowing at least some access to Squeak, an icon is added to the system tray. If you double-click this icon, the Squeak window will show up again.
...
Ok, that's the first part. I thought I had the mod but it said: subscript out of bounds.
What does that error mean?
I'm not sure if I will get this done on my own but I'll see ^^
Joren
Offline
I'm oviously not sombody that could do this- I was confused after the first sentnece. XD
Offline
Oh Help.
I added
ScratchScriptEditorMorph saveScriptsToImage.
at the end of
ScratchFrameMorph>importSpriteOrProject:
but it just gives a red error box with
Message not understood: saveScriptsToImage
I'm really a smalltalk noob and I don't always understand the special syntax
Offline
Who said jens was no longer with us? 0_o
Offline
Hi JSO,
I think you can access the picture of the stage in its current form by calling
workpane imageForm
from within ScratchFrameMorph.
If you're just interested in reading / exporting the thumbnail that's already stored in a saved Scratch project, you can extract that information by retrieving the entry associated with 'thumbnail' in the Scratch project's info dictionary. Look up method #extractInfoFrom: aByteArray in class ScratchFrameMorph. You can get the ByteArray needed by calling something like:
| file filename project info thumb|
filename := 'myScratchProject.sb'.
file := FileStream readOnlyFileNamedOrNil: filename.
project := self extractProjectFrom: file binary contentsOfEntireFile.
info := self extractInfoFrom: project.
thum := info at: 'thumbnail'
What you get is a bitmap (of class Form). Look there to find out how to save it!
Offline
But I wasn't trying to export the project thumbnail
I want to export the scripts snapshot when loading a sprite file, and to export the sprite thumbnail on import...
Thanks a lot for your support though
EDIT: I can export a sprite thumbnail with the stage image though. I'll see. From one i've seen in importSpriteOrProject the .sprite file format is very similar to the .sb (or .scratch, it was somewhere in there too) file format.
Last edited by JSO (2010-01-26 11:53:39)
Offline
Ah, okay. I guess you just need to make sure to send #saveScriptsToImage to the stage's (or sprite's) blocksBin, not to the stage/sprite itself. Try adding #blocksBin before the #saveScriptsToImage.
Offline
Oh well.
I just can't seem to do it, I'll spend some time reading online tutorials soon, but I really need this mod
Can someone please, please do the script export thing for me?
I will then learn some more squeak and do the sprite thumb export myself, that isn't really neccesary. My server is also ready now...
Thanks a lot in advance,
Joren
Offline
Idk
This Source Code mod has nothing to do with php though
And I'd love to let you help on the main site, but it's just really difficult to work together on PHP scripts as they need to run on the server and I'd need to give you the server login etc...
I might setup a testing server so all Scratchers uinterested in PHP can help... I'll see
But still,
Can someone, please, please help me out with these rather small mods?
Offline
JSO wrote:
Idk
This Source Code mod has nothing to do with php though
![]()
And I'd love to let you help on the main site, but it's just really difficult to work together on PHP scripts as they need to run on the server and I'd need to give you the server login etc...
I might setup a testing server so all Scratchers uinterested in PHP can help... I'll see![]()
But still,
Can someone, please, please help me out with these rather small mods?
Yeah, working together might cause some serious screw-ups
Offline
Wish I could help. I don't even know(yet) how to save the changes in the System Browser on a Mac yet!

Offline
shamrocker wrote:
Wish I could help. I don't even know(yet) how to save the changes in the System Browser on a Mac yet!
![]()
![]()
Thanks anyway
Please, someone...
I'll credit you everywhere if that makes you happy xD In my sig, on the site, in a project, in a thank-you forum thread xD
Offline
I don't have any answers but I do have a few questions...are you running Scratch Resources off of your own server and are you planning to run Squeak server-side to create the thumbnails?

Offline