in reply to Re^2: Using Image::Size
in thread Using Image::Size

Ok, knowing your skill level is always a plus on how we approach helping you. So we'll take it in smaller steps here. First question: is the directory name right? If you run "dir ..\images\dir\name" if Windows or "ls ../images/dir/name" if Linux/unix, do you see the files you want to work with? If not, you need to convert to using the right directory names.

There are ways to do this dynamically as something relative to where your script lives, but let's not cover too much ground in a single node here, so it may just be easier to put in the full path name such as "C:/images/dir/name" on Windows or "/home/kmarshall/images/dir/name" on Linux/unix. We can cover doing this in other ways at another time.

Ok, now next step. Just put the following in your program:

@files = glob '/home/kmarshall/images/dir/name/*'; use Data::Dumper; print Dumper(\@files);
and tell us what it says. Of course, put in the right path name that applies to where your images are.

Once we have gotten that far, it will be much easier to continue on from there.

Replies are listed 'Best First'.
Re^4: Using Image::Size
by kmarshall (Novice) on Sep 24, 2005 at 03:07 UTC
    I used the following code with the right path:
    @files = glob '/home/kmarshall/public_html/images/KYX/Eta Class/*.{jpg +,JPG}'; use Data::Dumper; print Dumper(\@files);
    This gave me the following: $VAR1 = '/home/kmarshall/public_html/images/KYX/Eta' ;

    It is important to note that the last directory in the out put is only "Eta" and not "Eta Class" like the code specified. I am not sure what this means.

    Thanks,
    Kyle

      It means that having spaces in your filenames is a very, very bad idea. Now I see why you need to use opendir/readdir/closedir. This was very relevant information that you omitted in your original post that led towards a suboptimal suggestion from me.

      My first recommendation is to remove the space. Either chop it out or change it to underscore. That will simplify your life in many ways.

      The next suggestion is to switch to using File::Glob::bsd_glob. You can do that by changing your @files line to:

      use File::Glob qw(:glob); @files = bsd_glob '/home/kmarshall/public_html/images/KYX/Eta Class/*. +{jpg,JPG}';
      The difference between glob and bsd_glob is that glob first splits on spaces and then calls bsd_glob for each item. bsd_glob will treat its parameter as a single glob to be dealt with - so the space doesn't have any meaning other than a character in the file name.

        That worked great! It now displays all of the filenames with the dimensions.

        Thank you so much for you help. I am sorry that I was doing some things wrong, like I said, I am new to Perl.

        Thanks again,
        Kyle