# Passing an image from the Servoy media library into a plugin

**URL:** <https://forum.servoy.com/t/passing-an-image-from-the-servoy-media-library-into-a-plugin/2383>\
**Category:** Classic Servoy\
**Created:** [August 2, 2004, 7:51am UTC](https://forum.servoy.com/t/passing-an-image-from-the-servoy-media-library-into-a-plugin/2383 "2004-08-02T07:51:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 2, 2004, 7:51am UTC](https://forum.servoy.com/t/passing-an-image-from-the-servoy-media-library-into-a-plugin/2383/1 "2004-08-02T07:51:40Z")

</div>

Hi,

Been strugling with this for a while now, cannot find a way to do it…

I’m trying to pass an image from the Servoy Media library into a plugin. So far no succes.

I think on the Servoy side I would have to do something like:

plugins.PBS\_Tools.insertImage(plugins.http.getMediaData(“media:///image.gif”))

But on the plugin side, how do I retrieve it again? This is what I have now, but this in combination with the way I call the function in Servoy doesn’t work…:

public void js\_insertImage (Image image)  
{  
bladibladibla;  
}

Any help appreciated..

Paul

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [August 2, 2004, 9:19pm UTC](https://forum.servoy.com/t/passing-an-image-from-the-servoy-media-library-into-a-plugin/2383/2 "2004-08-02T21:19:12Z")

</div>

In the plugin java code you can open an inputstream from an URL  
like:  
InputStream is = new URL(“media:///image.gif”).openStream();  
from the stream you can read the bytes. (do not forget to close the steam!)

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 3, 2004, 9:49am UTC](https://forum.servoy.com/t/passing-an-image-from-the-servoy-media-library-into-a-plugin/2383/3 "2004-08-03T09:49:28Z")

</div>

Jan,

Tnx for the pointer. Didn’t get that up and running, but looking at it from that angle, I found the following that works:

String name2 = “media:///” + name;  
URL url = new URL(name2);  
Image image = ImageIO.read(url);

In the sample above, name is a string that the function needs as parameter.

Is this a good way to achieve the same? As far as I understand it, there’s nothing I have to close now, right?

Paul

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [August 3, 2004, 5:25pm UTC](https://forum.servoy.com/t/passing-an-image-from-the-servoy-media-library-into-a-plugin/2383/4 "2004-08-03T17:25:48Z")

</div>

correct
