Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl Script to Resize Images .jpgs (and .gifs too)

Reply
Thread Tools

Perl Script to Resize Images .jpgs (and .gifs too)

 
 
dub
Guest
Posts: n/a
 
      12-12-2005
Hi folks... I'm trying to find a perl script that I can hopefully
reference from a http link (like
http://www.mysite.com/cgi-bin/resize....jpg&width=100). I
need it to shrink down uploaded user profile pics to a maximum width.
I have a lame server which won't let me install Image magick, but it
does have NETPBM and GDLib (though I don't want to use PHP for this).


I have exhausted all search engine possibilities... any help would be
VASTLY, Greatly appreciated.

Thanks
dubious

 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      12-12-2005
dub wrote:
> Hi folks... I'm trying to find a perl script that I can hopefully
> reference from a http link (like
> http://www.mysite.com/cgi-bin/resize....jpg&width=100). I
> need it to shrink down uploaded user profile pics to a maximum width.
> I have a lame server which won't let me install Image magick, but it
> does have NETPBM and GDLib


What you want can probably be written in a rather small Perl script
using the GD CPAN module.

If, OTOH, you are looking for a ready-to-go script, you have come to the
wrong place.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
 
dub
Guest
Posts: n/a
 
      12-12-2005
Ahh yes I realize that one can be written using the available
libraries. What I'm looking for is indeed a ready to go script. Does
anybody know of one?

Thanks,
Dubious

 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      12-12-2005
[ Dear Dubious,
You replied to a message in the Usenet group comp.lang.perl.misc. Even
if you posted from an interface provided by Google, most readers use
other tools for reading Usenet groups. Hence it's very important to
provide some context when you reply to a message, or else people who
might be able to help won't have a clue what you are talking about.
Typically that's accomplished by quoting parts of the message you are
replying to. ]

dub wrote:
> Gunnar Hjalmarsson wrote:
>> dub wrote:
>>> Hi folks... I'm trying to find a perl script that I can hopefully
>>> reference from a http link (like
>>> http://www.mysite.com/cgi-bin/resize....jpg&width=100). I
>>> need it to shrink down uploaded user profile pics to a maximum width.
>>> I have a lame server which won't let me install Image magick, but it
>>> does have NETPBM and GDLib

>>
>> What you want can probably be written in a rather small Perl script
>> using the GD CPAN module.
>>
>> If, OTOH, you are looking for a ready-to-go script, you have come to the
>> wrong place.

>
> Ahh yes I realize that one can be written using the available
> libraries. What I'm looking for is indeed a ready to go script. Does
> anybody know of one?


I don't. And personally I would write it rather than looking for it,
since it's a rather simple script you need.

Of course, if you don't know any Perl it _might_ be worth a try.
But, again, then you have come to the wrong place. You'd better look at
places like http://www.cgi.resourceindex.com/Pro..._Scripts/Perl/

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
Todd W
Guest
Posts: n/a
 
      12-12-2005

"dub" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi folks... I'm trying to find a perl script that I can hopefully
> reference from a http link (like
> http://www.mysite.com/cgi-bin/resize....jpg&width=100). I
> need it to shrink down uploaded user profile pics to a maximum width.
> I have a lame server which won't let me install Image magick, but it
> does have NETPBM and GDLib (though I don't want to use PHP for this).
>
>
> I have exhausted all search engine possibilities... any help would be
> VASTLY, Greatly appreciated.
>


Here is some code I used for a demo that uses the Perl<->GD bindings
(GD.pm). It only does jpeg, but it would be easy to modify. You can see it
work at:

http://waveright.homeip.net/products/demos/jpg2thumb/

#!/usr/bin/perl
use warnings;
use strict;

use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use CGI; my $q = CGI->new();

use GD;
use Image::GD::Thumbnail;

if ( $q->param ) {
my $fh = $q->upload('theImage');

# Load your source image
my $srcImage = GD::Image->newFromJpeg( $fh );

# Create the thumbnail from it, where the biggest side is
$q->param('theSize') px
my($thumb,$x,$y) = Image::GD::Thumbnail::create($srcImage,
$q->param('theSize'));

print $q->header(-type => 'image/jpeg');
binmode( STDOUT );
print $thumb->jpeg;

} else {
print $q->header(-type => 'text/html');
print $q->start_html( -title => 'jp(e)g to thumbnail converter' );
print $q->h1( 'jp(e)g to thumbnail converter' );
print $q->br( { width => '75%' } );
print $q->div( 'jp(e)g to thumbnail converter' );
print $q->div( '&nbsp;' );
print $q->div( 'Enter A jp(e)g File Name: ' );
print $q->start_multipart_form();
print $q->div(
'Size in pixels you wish the longest side to be: ',
$q->textfield(
-name => 'theSize',
-size => 3,
-default => '100',
-override => 1,
)
);
print $q->div( '&nbsp;' );
print $q->div( $q->filefield('theImage', '', 50) );
print $q->div( '&nbsp;' );
print $q->table(
$q->Tr(
$q->td( $q->submit ),
$q->td( $q->reset )
)
);
print $q->endform;
print $q->end_html;
}

Enjoy,

Todd W.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to resize all images sizes and coordinates of the images on resize browser rams.kakara@gmail.com ASP General 2 02-13-2005 09:03 AM
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments