image.setIDs();
image.setValue(Image._A_TITLE, getName(filename, directoryUsage));
image.setValue(Image._SYS_FILENAME, filename);
Picture pic = (Picture) DcModules.get(DcModules._PICTURE).getItem();
DcImageIcon icon;
if (filename.toLowerCase().endsWith(".svg")) {
SVGtoBufferedImageConverter converter = new SVGtoBufferedImageConverter();
BufferedImage bi = converter.renderSVG(filename);
icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(bi), 400, 400));
filename = File.createTempFile(String.valueOf(Utilities.getUniqueID()), ".png").toString();
icon.setFilename(filename);
icon.save();
bi.flush();
} else {
icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(filename), 400, 400));
pic.setValue(Picture._G_EXTERNAL_FILENAME, filename);
}
int width = icon.getIconWidth();
int height = icon.getIconHeight();
image.setValue(Image._F_WIDTH, width != -1 ? Long.valueOf(width) : null);
image.setValue(Image._G_HEIGHT, height != -1 ? Long.valueOf(height) : null);
icon.getImage().flush();
pic.setValue(Picture._A_OBJECTID, image.getID());
pic.setValue(Picture._B_FIELD, image.getField(Image._I_IMAGE).getDatabaseFieldName());
pic.setValue(Picture._D_IMAGE, icon);
pic.isEdited(true);