On 10/13/2014 06:16 PM, Rolf Huehne wrote:
> To get rid of the last pink pixels and to reduce the manual work even
> more export as PNG with transparent would be better.
>
I have written a Jmolscript function that facilitates exporting PNG 
files for an animation:

function exportAnimation(baseFilename, sizeX, sizeY, stepCount, 
stepCommandSet) {
   var printFormat = "" + baseFilename + "_%0" + stepCount.length + "d.png";
   var savedBackgroundColor = backgroundColor;
   background [x101010];
   for (var i=1; i<=stepCount; i++) {
     var filename = format(printFormat, i);
     var writeCommand = "write IMAGE " + sizeX + " " + sizeY + " PNGT 9 
" + fileName;
     var dummy = script(writeCommand);
     dummy     = script(stepCommandSet);
   }
   background @savedBackgroundColor;
}

Here is an example call that will generate 72 PNG images 
(jmol_movie_01.png, jmol_movie_02.png,...) with transparent background 
(500x500 pixel) where the molecule does a full 360 degree rotation in 5 
degree steps:

exportAnimation("jmol_movie", "500", "500", "72", "rotate axisangle {1 1 
0} 5");

The 'stepCommandSet' parameter can contain any set of Jmolscript 
commands separated by semicolon. They are executed each time after an 
image is written.

The background color is set here temporarily to the color proposed in 
the documentation as example for writing PNGT images. I have done this 
because not all background colors seem to work. "white" for example did 
result in a white background color instead of a transparent one in the 
exported images (Jmol 14.3.7).

In the applet unfortunately a file select dialog box pops up for every 
PNG file. I guess this is a security measure from the browser and you 
will not be able to avoid it.
Bob, the compression factor set in the dialog box ignored the setting 
from the command (in Firefox 32 on Linux). Fortunately it was at least 
remembered for the other images after it was changed within the dialog box.

With GIMP you can now very easily generate an animated GIF file in only 
four steps:

1) Create a new image (RGB mode) with the same size as the PNG images 
(500 x 500 pixel in the example above)

2) Add all PNG files in a single step with "File->Open as layers" from 
the menu. You should be able to select all files by selecting the first 
file with the mouse and the last file with SHIFT-mouseclick. Make sure 
that they are ordered by name. Otherwise you would have to reorder the 
layers later.

3) Delete the empty background layer at the bottom. (It was created in 
step 1.)

4) Export the image as GIF file and set the paramters in the dialog box 
that should appear after you selected the filename according to your 
liking for the animated GIF.

If you would also save the image in XCF format you could keep the full 
color information there. The conversion to "indexed" mode is done 
automatically just for the saved GIF image. You could also do it 
manually before saving as GIF. Then you would have some control over the 
conversion parameters.

Regards,
Rolf

-- 

Rolf Huehne
Postdoc

Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany

Phone:   +49 3641 65 6205
Fax:     +49 3641 65 6210
E-Mail:  [email protected]
Website: http://www.fli-leibniz.de

           Scientific Director: Prof. Dr. K. Lenhard Rudolph
        Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein

VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to