Hey Guys, here's a pretty useful block (I think nXIII made this, it might have been MathWizz though)
get web image: $String$
| img newC |
(t1 asLowercase endsWith: '.gif') ifTrue: [
img _ (GIFReadWriter new setStream: (HTTPSocket httpGet: t1)) nextImage.]
ifFalse: [
(t1 asLowercase endsWith: '.png') ifTrue: [
img _ (PNGReadWriter createAFormFrom: (HTTPSocket httpGet: t1) contents) first]
ifFalse: [
img _ HTTPSocket httpJpeg: t1]].
newC _ ImageMedia new form: img; mediaName: (self unusedMediaNameFromBaseName: (self defaultImageMedia mediaName)).
self addMediaItem: newC.
This block very amazingly imports web images as costumes to your Panther project.
One problem, it's not importing scratch project images... go to your projects, right click on one of the project thumbnails and select "copy image location" to get the image url, then paste it into the block an a red error message comes up... can anyone fix this?
thanks
Offline
Me either, but worse, when you try and go to the costumes tab a red error message pops up:
division by 0
Code:
SmallInteger(Object)>>error: SmallInteger>>/ ImageMedia>>thumbnailFormExtent: MediaItemMorph>>buildSubmorphs MediaItemMorph>>scratchObj:media: [] in ScratchSpriteMorph(ScriptableScratchMorph)>>costumesPage: OrderedCollection>>do: ScratchSpriteMorph(ScriptableScratchMorph)>>costumesPage: ScratchScriptEditorMorph>>currentCategory: ScratchTabPaneMorph>>currentTab:
Offline
MathWizz wrote:
No, I mean what url is your image at?
get. on. hamachi. now. i. want. to. talk. now.
Offline
ProgrammingFreak wrote:
MathWizz wrote:
No, I mean what url is your image at?
get. on. hamachi. now. i. want. to. talk. now.
Stay. On. Topic.
Offline
the url is taken by copying the image source address. It can be the icon for a project such as
http://scratch.mit.edu/static/projects/Sheepworld/1598169_sm.png
or the icon for a username, such as
http://scratch.mit.edu/static/icons/buddy/183006_med.png
Oddly enough I can import the image for my scratch image without a problem
http://scratch.mit.edu/static/icons/buddy/183006_med.png?t=2010-08-29+11%3A58%3A09
(any idea why mine has a load of code after the .png and the others don't? it needs to be there for it to work...)
Offline
sparks wrote:
the url is taken by copying the image source address. It can be the icon for a project such as
http://scratch.mit.edu/static/projects/Sheepworld/1598169_sm.png
or the icon for a username, such as
http://scratch.mit.edu/static/icons/buddy/183006_med.png
Oddly enough I can import the image for my scratch image without a problem
http://scratch.mit.edu/static/icons/buddy/183006_med.png?t=2010-08-29+11%3A58%3A09
(any idea why mine has a load of code after the .png and the others don't? it needs to be there for it to work...)
Mine has it aswell.
http://scratch.mit.edu/static/icons/buddy/84283_med.png?t=2010-05-15+12%3A32%3A49![]()
... It works with and without.
Offline