Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-16 04:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found