writing image from blob to disk

I am trying to write an image from the image-lib to harddisk but so far
I cannot write the image to the imagefield.
TIA.

This is my code:

var getpicture = plugins.images.getImage(‘media:///myimage.png’).getData();
if (!getpicture) {plugins.dialogs.showWarningDialog(‘Warning’, Could not store picture’, ‘OK’)}

var fileName = ‘c:/tempfolder/myimage.png’
var success = plugins.file.writeFile(fileName,imagefield);
if (!success) {plugins.dialogs.showWarningDialog(‘Warning’, ‘Could not write file’, ‘OK’)}

In your code you are writing “imagefield”. Why don’t you write “getpicture”?

You’re absolutely right Patrick, but I accidentely deleted the line:
imagefield=getpicture
Indeed it is more elegant not to use a temporary imagefield but
rather stick to the variable.
Nevertheless I still can’t get the picture (:wink:) so
there must be something wrong in the first line of code.
I am absolutely sure ‘myimage.png’ is in the lib.
Do you know what it can be?

Thanks for your time.
Ron

Without trying myself: is the getpicture variable filled with the image?

I got the error dialog (line 2) so I assume the var is empty.

Ron

Just tried. With the image plugin this does not seem to work. However, this works for me:

var vImage = plugins.http.getMediaData('media:///test.png');
plugins.file.writeFile('D:\\test.png', vImage);

Yep it works!!
Danke vielmals Patrick.

Ron

Bitte, gerne. :lol: