Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^3: Recursive image processing (with ImageMagic)

by zentara (Archbishop)
on Nov 24, 2012 at 09:54 UTC ( #1005350=note: print w/replies, xml ) Need Help??

in reply to Re^2: Recursive image processing (with ImageMagic)
in thread Recursive image processing (with ImageMagic)

It also makes the directory handling more complicated as I need to check or create (regardless) the output folder for and every file created. Unless, I suppose, File:Find returns files in blocks so I can check the last folder created and only mkdir when needed.

Well if you think about it, you have to test each file and directory to find out if you are in the right one, then if each file in that subdir has a .png ending.

I think to save cpu cycles, in your case, I would run File::Find with a directory test before the file test. $File::Find::prune = 1 will skip processing any files in that subdir. Something like:

find sub { # first filter out your directories if (-d && $_ !~ / my_target_dirs_regex / ) { $File::Find::prune = 1; return; } # if you make it to here, you are in your target subdir # now do your ImageMagick processing and mkdir # it has to check each file for a .png ending if (-f && $_ =~ / (.*)\.png$ / ) { # do mkdir stuf # do ImageMagick stuff } # or you could just push the files into an array for later processing # push @goners, $File::Find::name; }, @ARGV;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005350]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2017-10-22 18:01 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (274 votes). Check out past polls.