Eng:Capturing Images of Scripts (1.4)

In this tutorial we will be explaining how to capture an image of a script and save an image file of your Scratch blocks to your computer. Currently, only the Scratch 1.4 editor can directly save images of scripts.

In Scratch Method


The easiest way to save an image file is to right-click in the Scripts Area and press the "save picture of scripts" button. This method is the easiest, however it does not offer the best resolution possible, because it saves the images in a .gif file format. .gif files are indexed to a certain set of 256 colors, which causes the colors of the blocks in these images to change slightly. Even though .gif files have their shortcomings, this method can still be used to create clear block images.

Prior to Scratch 1.4, this feature did not work correctly, and added a gray area around the image.

Image Editing Method
This method is a more difficult and tedious method of taking images of scripts. First you will have to take a screenshot of your script. Once you have your screenshot, open the screenshot in your preferred image editor. You will now have to remove the background of your scripts. Once done you must save the image, preferably in the .png file format. This method, however, is more time consuming, but it may produce a clearer image.

Scratch Editing Method
In this method, the System Browser must be opened and edited. Navigate to.

PNG or GIF
Paste in the following code:

saveScriptsToPNG | t1 t2 | t2 _ pageViewerMorph contents screenshot. t1 _ ScratchFileChooserDialog chooseNewFileDefault: '' title: 'Save Scripts Snapshot' type: #scriptsSnapshot. t1 = #cancelled ifTrue: [^ self]. t1 size = 0 ifTrue: [^ self]. (t1 asLowercase endsWith: '.png') ifFalse: [t1 _ t1, '.png']. t2 writePNGFileNamed: t1

Accept. (Right-click and choose accept or press Alt + S.)

Go to the method. Replace it with the following code:

scriptsMenu: t1 	| t2 t3 | self target ifNil: [^ self]. t2 _ CustomMenu new. t2 add: 'clean up' action: #cleanUp. t2 add: 'save picture of scripts (PNG)' action: #saveScriptsToPNG. t2 add: 'save picture of scripts (GIF)' action: #saveScriptsToImage. t2 add: 'add comment' action: #addComment:. t3 _ t2 localize startUp. t3 ifNil: [^ self]. t3 = #addComment: ifTrue: [self perform: t3 with: t1] ifFalse: [self perform: t3]

You may notice it only adds the line:

This calls the  method we just made. Accept. Save image for end user.

When the Scripts Area is clicked, the following menu will come up: The "save picture of scripts (PNG)" works exactly the same as a GIF but saves in a different file format.

PNG Only
If a GIF will never be wanted, the  method can be changed to the following: saveScriptsToImage | t1 t2 | t2 _ pageViewerMorph contents screenshot. t1 _ ScratchFileChooserDialog chooseNewFileDefault: '' title: 'Save Scripts Snapshot' type: #scriptsSnapshot. t1 = #cancelled ifTrue: [^ self]. t1 size = 0 ifTrue: [^ self]. (t1 asLowercase endsWith: '.png') ifFalse: [t1 _ t1, '.png']. t2 writePNGFileNamed: t1

The  method need not be edited.

Type PNG or GIF
In this method, it opens the regular dialog, and saves as a PNG unless the filename is specified to end with " ".

Replace the  method with the following code:

saveScriptsToImage | t1 t2 | t2 _ pageViewerMorph contents screenshot. t1 _ ScratchFileChooserDialog chooseNewFileDefault: '' title: 'Save Scripts Snapshot' type: #scriptsSnapshot. t1 = #cancelled ifTrue: [^ self]. t1 size = 0 ifTrue: [^ self]. (t1 asLowercase endsWith: '.gif') | (t1 asLowercase endsWith: '.png') ifFalse: [t1 _ t1, '.png']. (t1 asLowercase endsWith: '.gif') ifTrue: [t2 writeGIFFileNamed: t1] ifFalse: [t2 writePNGFileNamed: t1]

If simply " " or " " is typed, it will save as a PNG, but if " " is typed, it will be a GIF file.

The  method need not be edited.

Comparison
The GIF image is very slightly darker colored than the PNG image, but the difference is barely noticeable.

de:Scratch-Wiki:Hilfe:Screenshots von Blöcken freistellen