[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: trying again: automaticly image width and height

Subject: Re: trying again: automaticly image width and height
From: Benjamin Franz <snowhare@xxxxxxxxxxx>
Date: Sat, 12 May 2001 07:06:02 -0700 (PDT)
perl image width height
On Sat, 12 May 2001, Janning Vygen wrote:

> Am Samstag, 12. Mai 2001 00:41 schrieb Peter Flynn:
> > > heres my question again: i tried some extension from lunatech to
> > > insert width and height into the img tags of a html nod set. i cant
> > > find the lunatech extensions in the internet again, so i cant ask
> > > them why the i get an input stream error after about 400 images.
> >
> > Memory leaks?
> 
> i am running linux

That doesn't mean anything. Memory leaks are nearly always a problem with
the _program_, not the operating system. The following trivial program
would leak memory on *any* system, for example. Watch it with 'ps' or
'top' and you can see it steadily grow. 


#!/usr/bin/perl -w

use strict;
use Image::Size;

local $/;
my $data = {};
foreach (@ARGV) {
    next if (! -f $_);
    if (not open(DATA_FILE,$_)) {
        warn("Could not open $_: $!\n");
        next;
    }
    $data->{$_} = <DATA_FILE>;
    close(DATA_FILE);
    print ("$_ : " . length($data->{$_}) . " bytes\n");
    my $image = $data->{$_};
    my ($width,$height,$type) = imgsize(\$image);
    next if (not defined $width);
    print ("   height - $height, width - $width, type - $type\n");
    sleep 1;
}

If you are using a Java based tool, odd are heavy that you are running in
the default 64Mb heap - which goes boom fairly quickly if you have a leak.
A work around (assuming you have enough real/virtual mem for the number of
images you are going to be handling) is to invoke java with the -Xmx (see
'java -X' for info on it) flag and increase the heap space. Another work
around is run 'non-persistently'. IOW if you are processing many documents
and that is why you need 400+ images processed but no individual document
has very many, reinvoke the *entire* program for each document processed.

#!/usr/bin/perl -w
use strict;

foreach my $document (@ARGV) {
	# Call program here using
        # the 'system' call with whatever
        # the appropriate parameters are.
        system('java','program.jar',$document);
}

-- 
Benjamin Franz

"Premature optimization is the root of all evil in programming."
                                         ---C.A.R. Hoare





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.