byte[] imgData = downloadRessource(imgUrl);
String fileExt = RessourceManager.guessImageExtension(imgData);
File f = File.createTempFile("tmp", "." + fileExt);
f.deleteOnExit();
Tools.writeFile(f.getAbsolutePath(), imgData);
WFImage img = new ImageReader(new JLabel()).loadImage(f.getAbsolutePath());
if (img.getImageWidth() >= minSize && img.getImageWidth() <= maxSize && img.getImageHeight() >= minSize && img.getImageHeight() <= maxSize) {
int hashcode = RessourceManager.calcHashCode(imgData);
SimpleImage wfImg = (SimpleImage) RessourceManager.getImage(hashcode, imgData);
RGBPalette gradient = new MedianCutQuantizer().createPalette(wfImg);
return new ImageData(pageUrl, imgUrl, imgData, gradient);