Reading the first .jpg file from a .rar archive?

K

K P S

Can someone please point me to a small script to read the first .jpg
file from a .rar archive? I would like to create thumbnails of an
archive based on the first image file in the archive.

Also, are there perl routines for image manipulation? ie: scaleing an
image and converting from .jpg to .png?

I'm obviously someone totally new to perl, so any help would be
appreciated

Thanks!
 
D

David Squire

K said:
Can someone please point me to a small script to read the first .jpg
file from a .rar archive? I would like to create thumbnails of an
archive based on the first image file in the archive.

Also, are there perl routines for image manipulation? ie: scaleing an
image and converting from .jpg to .png?

I'm obviously someone totally new to perl, so any help would be
appreciated

Then you need to know about CPAN. Go to http://search.cpan.org/ and
search for rar. At CPAN, you will find modules to help you with this and
many other tasks.

DS
 
D

DJ Stunks

K said:
Can someone please point me to a small script to read the first .jpg
file from a .rar archive? I would like to create thumbnails of an
archive based on the first image file in the archive.

define "first"

-jp
 
K

K P S

1. The ordinal number matching the number one in a series.
2. The one coming, occurring, or ranking before or above all others.

While I've never heard of a 'rar' archive, I'm guessing that like most
archive formats, it has a list of files in the header/trailer -- so
the 'first' would be that filename that matches .jpg$ before any
other.

Rar is a file compression format similar to zip. The wikipedia entry
is: http://en.wikipedia.org/wiki/RAR_(file_format)

The perl module is found here:
http://search.cpan.org/~jmbo/Archive-Rar-1.9/Rar.pm

I unfortunately don't know much about perl to begin with, but I'm
taking a stab at this: I want a small application that will take two
arguements, the first a .rar file, and the second a file name. It will
extract the first .jpg file from the archive, convert it to .png
format, and save it as the file name in the second arguement.

The reason is to create thumbnails of .rar files based on their
contents, in nautilus.
 
P

Peter J. Holzer

K said:
Can someone please point me to a small script to read the first .jpg
file from a .rar archive? I would like to create thumbnails of an
archive based on the first image file in the archive.

Also, are there perl routines for image manipulation? ie: scaleing an
image and converting from .jpg to .png?

Several.

I have used the Imager module for this kind of stuff:

For example, here is a snippet of a script which scales down images to
at most 300x300 pixels (if they are already smaller they are left alone)
and stores them as JPEG files (the input files in this case usually are
JPEG, too, but don't have to be):

use Imager;
[...]
# Scale photo to useable size

my $img = Imager->new();
if ($img->open(file=>$mg->photo())) {
my $newimg = $img->scale(
xpixels => ($img->getwidth < 300 ? $img->getwidth: 300),
ypixels => ($img->getheight < 300 ? $img->getwidth: 300),
type => 'min');
$newimg->write(file=>"$document_root/mitglieder/$dir/photo.jpg")
or die "cannot write $document_root/mitglieder/$dir/photo.jpg: " . Imager->errstr; }

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top