Importing backgrounds or pictures
Hi, First of all thanks for the great work! My students love it. Although sometimes they'd like to import other backgrounds or pictures to play with. Is there a way to do this?
While there's not a built-in functionality to import pictures, the database is entirely contained in the documents/ScratchJR/scratchjr.sqllite file, which can be edited in a tool like DB Browser for SQLite. Here's my process for importing pictures into the program:
- Open ScratchJr Desktop and create placeholders for the graphics you want to import (name them so they're easy to locate);
- Close ScratchJr so you can edit the database file;
- Open the databasa file in SQLite Browser;
- Locate the entries for the placeholder objects you created (in tables USERBKGS and USERSHAPES) and take note of the MD5 field, which identifies the SVG data they use;
- Prepare the new images in SVG format (using Illustrator or Inkscape) and open the resulting files in a text editor;
- Copy the entire SVG code for each image and encode them as base64 strings, using a tool like this;
- Go to the PROJECTFILES table, look for the MD5 hashes you took note of before and replace the existing base64 strings in the CONTENTS field with the new ones (you don't need to change the MD5 field);
- Save your changes back to the database file and close it;
- Open ScratchJr again and the contents of your placeholder objects will have changed, but not their thumbnails;
- You can replace the thumbnails externally if you want, but it's easier to just "fake edit" the objects inside ScratchJr so it re-generates proper thumbnails automatically.
Note that you can also extract the SVGs from the database to your computer by doing the opposite procedure: copy the base64 SVG strings, decode them here, and save the output in text files with the .svg extension. These files can be edited in Illustrator or Inkscape, and imported back into ScratchJr through the steps above. This may be a good idea if you're worried about preserving the dimensions of the objects.
This is definitely not a process you'd have a young student do, but as a teacher you can have them create their graphics one day, so that you can insert the graphics yourself and bring an updated database file for the next class.
While there's not a built-in functionality to import pictures, the database is entirely contained in the documents/ScratchJR/scratchjr.sqllite file, which can be edited in a tool like DB Browser for SQLite. Here's my process for importing pictures into the program:
1. Open ScratchJr Desktop and create placeholders for the graphics you want to import (name them so they're easy to locate); 2. Close ScratchJr so you can edit the database file; 3. Open the databasa file in SQLite Browser; 4. Locate the entries for the placeholder objects you created (in tables USERBKGS and USERSHAPES) and take note of the MD5 field, which identifies the SVG data they use; 5. Prepare the new images in SVG format (using Illustrator or Inkscape) and open the resulting files in a text editor; 6. Copy the entire SVG code for each image and encode them as base64 strings, using a tool like [this](https://www.base64encode.org/); 7. Go to the PROJECTFILES table, look for the MD5 hashes you took note of before and replace the existing base64 strings in the CONTENTS field with the new ones (you don't need to change the MD5 field); 8. Save your changes back to the database file and close it; 9. Open ScratchJr again and the contents of your placeholder objects will have changed, but not their thumbnails; 10. You can replace the thumbnails externally if you want, but it's easier to just "fake edit" the objects inside ScratchJr so it re-generates proper thumbnails automatically.Note that you can also extract the SVGs from the database to your computer by doing the opposite procedure: copy the base64 SVG strings, decode them here, and save the output in text files with the .svg extension. These files can be edited in Illustrator or Inkscape, and imported back into ScratchJr through the steps above. This may be a good idea if you're worried about preserving the dimensions of the objects.
This is definitely not a process you'd have a young student do, but as a teacher you can have them create their graphics one day, so that you can insert the graphics yourself and bring an updated database file for the next class.
its really a difficult one to follow. what is placeholder in scratchJR. im googling and dont find any result to that.thanks for the help!
its really a difficult one to follow. what is placeholder in scratchJR. im googling and dont find any result to that.thanks for the help!
I think it means, just draw any simple sprite in the scratch-jr project, name it and than search for it in the database.
But i have a question too, if i open such a MD5 field in the database, i get no text to work with...