Just another perl hacker somewhere near Disneyland
I have this homenode [perlmonks.org] of little consequence on Perl Monks [perlmonks.org] that you probably have no interest in whatsoever.
I also have some modules [cpan.org] on CPAN [cpan.org] some of which are marginally [cpan.org] more [cpan.org] useful [cpan.org] than others.
I've written before about my obsession with Highway 395, but this time I have photos, many of which were taken out the car window (w/my wife's camera...someday I'll get my own), though one of my favorites was taken from inside the car, and one was actually from Lake Tahoe, but I included in the set anyway just because it was so awesome
I did find that the pictures coming out of the camera were at 2560x1920, and since I have the free flickr account, there is a limit on how many MB you can upload. Earlier, I had quickly used up the limit on my wife's account uploading full-size pictures, only to find that they get scaled to 1280x960 when you view the largest version of the image after it's uploaded, but you get "charged" for the actual uploaded size. So this time, I installed Image::Magick, found the documentation, and spent 5 minutes reading it to come up with this:
use Image::Magick;
my @files = <*.jpg>;
for my $file (@files) {
my $img = Image::Magick->new;
$img->Read($file);
$img->Scale(width=>1280, height=>960);
# Yes, I'm overwriting the file, but the whole
# directory is a copy
$img->Write($file);
}
I'm sure there must be other ways to do this, but this is what I came up with first, and it worked just fine, though I'd love to hear about alternatives, or anything wrong with the above
Shell rules. (Score:1)
I would do:
Shell rules.Re: (Score:1)
It always amazes me that people use ImageMagick. :-) What does the greater-than in your size specification mean? Why does ImageMagick have to have such an arcane interface that it shines through even in such a simple example? When I try to do multiple operations, I am always bamboozled by the precedence of the various options. Would that at least the image quality made it all worthwhile… but other tools usually do a much better job.
NetPBM usually loses out on brevity vs. ImageMagick, but pipes are
Re: (Score:1)
Re: (Score:1)
Yeah, you’re right, pnmscale doesn’t have that. You can code around it using pnmfile and explicit checks, but it’s awkward to say the least. Adding -enlargeonly and -reduceonly switches should be easy… (Another advantage of the small-tools philosophy: they all have short and mostly simple sources.) Maybe I’ll submit a patch.
Re: (Score:1)
I normally don't do that, but in this case, I was not aware of the command line tools (I've heard of ImageMagick for years now, but have only just now actually used it), and I only installed the PerlMagick package (on Windows w/ppm). If I do install the whole ImageMagick package, I'll have to do something about that 'convert' command, as there is already a 'convert' on Windows, which does something
NetPBM! (Score:1)
I hate ImageMagick. It’s slow and its algorithms often produce low-quality results. I don’t like trotting out Perl for small tasks involving fiddling with a lot of files either, the command line interface of ImageMagick is execrable. I use ImageMagick only when I am desperate.
So I recommend NetPBM [sourceforge.net] instead, which consists of a big bag of little programs that you connect together using pipes – a highly intuitive metaphor for image manipulation, I find. A shell script using NetPBM for yo
Re: (Score:2)
--
xoa
Re: (Score:1)
For the benefit of anyone who reads this: the one in moreutils [kitenet.net], I suppose. Thanks for the tip.