Newbie in the house! It's been about 5 years since I did any Perl but I've just been handed a problem which I suspect can be solved elegantly using a relatively short script.

I have a directory which contains other directories - some containing and a large (millions!) number of small PNG images. I need to make a copy of this directory structure into a new location, with all the images converted to greyscale. Yes, grey. I'm British and so am allowed to spell it like that. :-) The utility needs to run on a Windows platform.

I've already pre-selected ImageMagick to do the image processing and was originaly going to write a C/C++ program to do the job. However, when I noticed that ImageMagick has a Perl module, I started to recall that Perl has some nice built-in file system management which can be expressed concisely. I'm also aware there are a lot of modules out there which can do some clever things and save a lot of effort.

So, I'm looking at a utility which accepts a source directory and target directory as parameters. It will then scan through the source directory, recursing into sub-directories, and scan for PNG images. When it finds one, let PerlMagick do the hard work and write the output. Of course, I also need to create sub-directories on the output folder.

I wondered if anyone had created (something like) a recursive file copier which I could adapt to a recursive image processor? Alternatively, any help/guidance on the directory scanning and recursion would be appreciated, especially given the number of PNG images being processed (in each folder and overall). TIA.

Regards,
Warren


In reply to Recursive image processing (with ImageMagic) by wvick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.