emf image quality when exporting from API

User 37df300f74

16-12-2013 01:25:55

Hi There, I searched through your website before posting this question. I have Marvin 6.1 and if I export emf image from Marvin sketch and insert into powerpoint,  the re-sized image looks good. However if I use molecule.toBinFormat("emf with the same height/width), the quality is suffering. I am wondering whether you can share the parameter you use in GUI.


Thanks


Hongzhou

ChemAxon 4fa3cf533c

16-12-2013 08:18:33

Hello,


 


Did you try using MolExporter.exportToBinFormat(molecule,string)? 


Molecule.toBinFormat is a deprecated function, and it might not behave correctly.


You can find the api documentation to MolExporter here.


Hope this helps,


 


Tamas Fazekas-Vigh

User 37df300f74

16-12-2013 15:20:51

Thanks Tomas,


I switched to ExportBinFormat (m, "emf:w300,h300"), but the image quality look sketchy, just like toBinFormat(). I attached the image files generated from api for your review. Here is the smiles from PDB 1lEP.


CN1CCN(CC2=CC=C(C=C2)C(=O)NC2=CC=C(C)C(NC3=NC=CC(=N3)C3=CC=CN=C3)=C2)CC1

ChemAxon 4fa3cf533c

18-12-2013 13:36:15

Hello Hongzhou!


We use two different library to generate emf images in marvin, and if one fails, we fall back to use the other, which generates images you described as "sketchy". I advised you to use MolExporter.exportToBinFormat but I found out that in every scenario it uses the fall back library.


To use the .net generated emf you'll need an installed marvin on your computer, with .netapi installed (it's included within the installer, and installed during the install of the application), and you'll have to use 


ImageExportUtil


to generate proper vectorgraphics emf file.


I made a sample code for you to use:


	Molecule mol = null;
String mrvSource = null;
String fileName = "C:\\out.emf";
String exporterParamStr = "emf:w300,h300";
try {
mol = MolImporter.importMol("CN1CCN(CC2=CC=C(C=C2)C(=O)NC2=CC=C(C)C(NC3=NC=CC(=N3)C3=CC=CN=C3)=C2)CC1");
mrvSource = MolExporter.exportToFormat(mol, "mrv");
ImageExportUtil.generateEMFToFile(mrvSource, exporterParamStr, fileName);
}
catch (IOException e) {
e.printStackTrace();
} finally {
ImageExportUtil.releaseNewEMFGenerator();
}

 


It is important to use ImageExportUtil.releaseNewEMFGenerator() after you don't want to generate more emf images, because it uses native resources that have to released . 


Hope this helps,


Tamas Fazekas-Vigh

User 37df300f74

19-12-2013 21:10:32

Hi Tomsa,


Thanks for your explaination and sample codes. However I am looking for pure java solution since we don't want to bundle the whole set of .net libraries just for this purpose. I googled around and found svg2emf opensource java code which can convert svg file generated from Marvin to emf file with good quality. However the file size is more than 10 times larger and I have to use temp file as intermediate, rather on the fly. do you guys plan to do something about this from java side?


Happy holiday,


Hongzhou


 

ChemAxon f052bdfe3c

02-01-2014 12:08:45

Hi Hongzhou,



Unfortunately, this is not in our major focus currently.


Best Regards,


Efi

User 37df300f74

03-01-2014 19:35:42

I tried with ImageExportUtil function and the image quality is real good. However generateEMFToFile tooks a few seconds for a single image, while toBinFormat will generate 100 images with the same time, is this normal?


Thanks


hongzhou

ChemAxon 5433b8e56b

07-01-2014 10:51:32

Hi Hongzhou,


the problem as I think is that, you call the releaseNewEMFGenerator method after every image creation.


You should release the underlying .Net EMF generator module after you finished all the image generation. So please try to modify your code in a way where the releaseNewEMFGenerator method after all the images are generated.


Regards,
Istvan 

User 37df300f74

07-01-2014 14:00:09

Hi Istvan,


Thanks. I  guess it take quite a bit time to initiate the export function since the first time it will take a couple of seconds, then about 50 molecules can be precessed per second.


A follow-up question, if I want to make this function available to users who don't have Marvin installed locally, which .net library I need to bundle? I saw "EMFExport"  folder under "Shared" ,  are those all I need or other libraries also have to be included?


Thanks


Hongzhou

User 37df300f74

07-01-2014 18:43:41

Hi Istvan,


I did a quick test and it seems that all it need are two folders : DotnetClassLoader and EMFExport to generate quality emf image. However the exact file path was kind of hard-coded somewhere since if I move those dll to the current dictionary and delete from C:\Program Files (x86)\ChemAxon\Shared, then the image will not be generated. Also I used System.Load() function to specify the absolute location of those dlls, but did not wrok.  Is there a way to set up some kind of variables to tell java the customized location of those two folder? That would make it much easier to deliver this function to other users, who don't have MarvinBean installed.


Thanks a lot,


Hongzhou

User 37df300f74

08-01-2014 16:13:47

Hi there,


I dig deeper and realized CXNEmfExport is actually OLE/COM object. do you guys have a clean .Net library file for this purpose? ole/com need to be registered and require higher permission. We can use both .net and java approaches, but don't want to go through installation and registration process.


Thanks


Hongzhou

ChemAxon 2c555f5717

10-01-2014 10:34:28

Dear Hongzhou!


   Unfortunately we do not have any .Net library that do not need registration. We can only provide the pure Java solutions to be portable.


Regards:
Balázs