Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8803289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:18:08+00:00 2026-06-14T01:18:08+00:00

I have a working perl script that scans a directory and uses imgsize http://dktools.sourceforge.net/imgsize.html

  • 0

I have a working perl script that scans a directory and uses imgsize
http://dktools.sourceforge.net/imgsize.html to get the width, etc of png files. Does anyone have any tips for speeding up this process (right now, it averages 5 minutes for every 1000 files)? I was just wondering if the code could be optimized some how. Thanks.

use strict;
use warnings;

use File::Find;

my @files;
my $directory = '/Graphics/';
my $output_file = '/output_file';
my $max_height = 555;
my $count = 0;

open ( OUTPUT, '>>', $output_file );

find( \&wanted, $directory );

foreach my $file ( @files ) {
        if ( $file =~ /\.png$/ ) {
                my $height = `imgsize $file | cut -d\'\"\' -f4`;
                if ( $height > $max_height ) {
                        print OUTPUT "$file\n";
                }

                $count++;

                my $int_check = $count/1000;
                if ( $int_check !~ /\D/ ) {
                        print "processed: $count\n";
                }
        }
}

print "total: $count\n";
close ( OUTPUT );
exit;

sub wanted {
  push @files, $File::Find::name;
  return;
}

Solution: Turns out that I was able to use the Image::Info module. I went from processing 1000 imgs every 5 minutes to every 12 seconds. Here’s the relevant snippet of code, if anyone is interested:

 use Image::Info qw(image_info);

    foreach my $file ( @files ) {
            if ( $file =~ /\.png$/ ) {
                    my $output = image_info($file);
                    my $height = ${$output}{height};

                    if ($height > $max_height) {
                            print OUTPUT "$file\n";
                    }

                    $count++;

                    my $int_check = $count/1000;
                    if ( $int_check !~ /\D/ ) {
                            print "processed: $count\n";
                    }
            }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:18:10+00:00Added an answer on June 14, 2026 at 1:18 am

    The Perl code you’ve shown is likely not the culprit. You can profile it with Devel::NYTProf, just like @choroba has said. But I’d bet money that most of the time comes from forking two external processes per image (imgsize and cut). You should look into Perl modules that can retrieve the image’s height without running any external process. Modules like Image::Info come to mind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working perl script that grabs the data I need and displays
I currently have a perl script that imports HTML and converts it to plain
I have a Perl CGI script that isn't working and I don't know how
Good Day, I have a simple working routine in Perl that swaps two words:
I have working registration script the only problem is that i do not know
I have some regexes in a Perl script that are correct but slow. I
I have a shell script that I want to get the date and time
I have a Perl script that is calling a program on Windows using backticks.
I have the folling Perl script that I am using to import data directly
I've just started working with mongodb got a perl script that parses a twitter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.