Thumbnails and memory

I’m adding an image storage system to my main solution and I decided to create thumbnails in order to show them in a html field with the new, excellent blobloader function.
Anyway, I noticed that the memory usage is quite large: I just created a thumbnail from a 8 MB jpeg and if I hadn’t the chance to assign more memory to the client, I couldn’t accomplish the task: the memory usage raised from 16.000 to 114.000! (not to say it took almost 6 minutes to complete the procedure).
So, my question: is there only one way to create thumbnails?
For instance, wouldn’t it be possibile to create a reduced copy of the original file and then process this one instead of the big original?

Servoy 2.1rc3, MacOSx.3.5

how do you create thumbnails?
Because now with 2.1 you can use applicaiton.createThumbnail where you put in youre byte data (loaded from file or db dataprovider) and this will not take much memory.

jcompagner:
how do you create thumbnails?
Because now with 2.1 you can use applicaiton.createThumbnail where you put in youre byte data (loaded from file or db dataprovider) and this will not take much memory.

Sounds very promising, but when I try to use it, I always get an empty thumbnail field. My original method was:

//related record creation
forms.anagrafica.elements.tabindir.readOnly = false
forms.anagrafica.anagrafica_to_immagini.newRecord();
 filename = application.showFileOpenDialog();  
var rnd = Math.random();

if (filename)//for cancel  
 {  
 M-  M- var normalizedFileName = ""; 
 M-  M- normalizedFileName = utils.stringReplace(filename,'\\','/')//make windows path like unix path  
 M-  M- percorsoimmagine = normalizedFileName 
	var tmpfile = application.createTempFile(rnd,utils.stringRight(percorsoimmagine, 4))
	var idx = normalizedFileName.lastIndexOf("/");  
 M-  M- if (idx != -1) normalizedFileName = normalizedFileName.substring(idx+1 ); 
 M-  M- nomefile = normalizedFileName 
 M-  M- immagine = application.readFile(percorsoimmagine) 
 M-  M- dimensionefile = plugins.file.getFileSize(filename) 

forms.immaginielenco.elements.imago.setImageURL("file:///" + percorsoimmagine);
var jpgData = elements.imago.getThumbnailJPGImage(128,128);
application.writeFile(tmpfile, jpgData);
//thumbnail assignment
forms.immaginielenco.elements.imago.setImageURL("");

miniatura = application.readFile(tmpfile)
plugins.dialogs.showInfoDialog( "Importazione","L'immagine selezionata M-h stata inserita correttamente","OK")
 }

I tried to change it assigning to “miniatura” field a thumbnail getting data from the “immagine” field (which stores the hi-res image)

miniatura = application.createThumbnailJPGImage(immagine, 128, 128)

OR parking “immagine” value in a variable and then using it.

var jpgData =  immagine
miniatura = application.createThumbnailJPGImage(jpgData, 128, 128)

In both cases, I don’t get errors, but the result is an empty “miniatura” field: what I’m I missing?

nothing this way:

miniatura = application.createThumbnailJPGImage(immagine, 128, 128) 

should work fine.

i just made a very small test:

var file = plugins.file.showFileOpenDialog(1,  'c:/temp')
if(file)
{
	var data = application.readFile(file);
	apicture = application.createThumbnailJPGImage(data, 128, 128);
	aname = file.getName();
}

apicture and aname are columns in the db (media and text)

jcompagner:
nothing this way:

miniatura = application.createThumbnailJPGImage(immagine, 128, 128) 

should work fine.

Unfortunately I can’t get to work it correctly: the thumbnails is created every now and then (even with the same image file).
Moreover, I’m encountering other strange behaviours: when I launch a method from the generated html (using ahref), sometimes the method is fired 2/3 times.
I thought the problem could be related to the fact I was showing a global field formatted as html area in a tabpanel, so I changed it to a text field; but the problem is still present and I can’t trace it: sometimes it happens, sometimes it doesn’t.

I’m getting very confused ;-), so if you have any idea…

OSX.3.5, 2.1RC3

please send me a sample solution where you do these things and send me some images that you are trying to thumbnail.