This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Pages: 1 - Last Post: 24 Aug 09, 18:30 Last Post By: mrag
davidekholm

Posts: 3,542
Registered: 18-Oct-2002
Zipping images using Jalbum
Posted: 28 Aug 08, 12:47
 
  Click to reply to this thread Reply
Skin developers: Here is a script you can modify. It zips image files from the "slides" directory of an album to a zip file called "images.zip":
    import java.io.*;
    import java.util.zip.*;
 
    File rootDir = engine.getInterpretedOutputDirectory();
    File slidesDir = new File(rootDir, engine.getSlideDirectory());
 
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(new File(rootDir, "images.zip")));
    out.setLevel(Deflater.DEFAULT_COMPRESSION);
    byte[] buffer = new byte[18024];
    File[] imageFiles = slidesDir.listFiles();
    for (File f : imageFiles) {
        if (f.isDirectory() || f.getName().toLowerCase().endsWith(".html")) continue;
        FileInputStream in = new FileInputStream(f);
        out.putNextEntry(new ZipEntry(f.getName()));
        int len;
        while ((len = in.read(buffer)) > 0) {
            out.write(buffer, 0, len);
        }
        out.closeEntry();
        in.close();
    }
    out.close();
mrag

Posts: 335
Registered: 26-Jul-2003
Re: Zipping images using Jalbum
Posted: 22 Aug 09, 21:25   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
This a another great, but possibly underutilized feature of Jalbum. In theory, one could zip all the slides as a package to send on to family members, etc. I see two potential requirements here: 1) send ALL (reduced size) slides in an email or possibly send all carefully SELECTED* (full size) originals -this is detailed at:
http://jalbum.net/forum/thread.jspa?threadID=22380&tstart=0
(which still asks the question, why need to ALSO check "include originals" for the few selected?)

I know, this code should be incorporated into a a file named "finally.bsh" Beyond that, I've not a clue. Or does this become server side issues?

*the idea here is that out of a large number of photos, only a few would be such that people would actually want to download.

JeffTucker

Posts: 8,361
Registered: 31-Jan-2006
Re: Zipping images using Jalbum
Posted: 22 Aug 09, 22:12   in response to: mrag in response to: mrag
 
  Click to reply to this thread Reply
mrag wrote:
I know, this code should be incorporated into a a file named "finally.bsh" Beyond that, I've not a clue. Or does this become server side issues?

Not server-side. Putting that routine into finally.bsh would yield a file called images.zip in the Output Directory, created as the last step of "Make Album." You would upload it along with all the other stuff there. You could then link to it from within your album somewhere, or you could simply point visitors to the URL.

Just remember that zipping JPGs, while it does put them all into one file, doesn't shrink them. JPGs are already about as compressed as they can be.
mrag

Posts: 335
Registered: 26-Jul-2003
Re: Zipping images using Jalbum
Posted: 24 Aug 09, 18:30   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
I knew zipping a number of jpg's did not save much. One advantage though might be getting a single zip file in an email, versus an email with 25 separate photos attached where you have to individually download each one. Some of the "new" digital photo frames seem to accept reduced size Jalbum slides so a zip package there to Grandma might be helpful to her reloading her frame. Then, of course, you run into some mail hosts that don't allow zip files as attachments at all....

Jalbum now allows one to select individual originals to be included in an album. The routine David provided zips all the slide images. I was looking for an alternative or option that would allow only the selected originals to be "zipped."

Clearly, I would have modified the code myself, but my Swedish is quite limited ;-)
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums