Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Are there ways to resize pic without using CPAN modules

by seewhy (Initiate)
on Jun 17, 2005 at 11:11 UTC ( [id://467657]=perlquestion: print w/replies, xml ) Need Help??

seewhy has asked for the wisdom of the Perl Monks concerning the following question:

I have been trying to write a picture resizing tool such that when I upload my pictures, it will auto crop the pic to the desire size. I know this can be easily done using GD or Imager CPAN module. However, the web service provider that I use do not have these CPAN module installed. Does that mean I have to settle with PHP, or there is a way around?

Thank you for any suggestions.


  • Comment on Are there ways to resize pic without using CPAN modules

Replies are listed 'Best First'.
Re: Are there ways to resize pic without using CPAN modules
by mikeraz (Friar) on Jun 17, 2005 at 12:03 UTC

    If the module Image::Magick is available you have that option, see this page for details. If the module is not available and the program is you can fall back to backtick processing
      `convert $img_filename -resize ${tn_size}x$tn_size $tn_filename`

    Be Appropriate && Follow Your Curiosity
Re: Are there ways to resize pic without using CPAN modules
by salva (Canon) on Jun 17, 2005 at 11:50 UTC
Re: Are there ways to resize pic without using CPAN modules
by sgifford (Prior) on Jun 17, 2005 at 13:24 UTC
    Why can't you simply install whatever modules you want under your home directory? I do this all the time with a variety of hosting providers. See Re^2: Perl module for a sample of how to do it if your provider doesn't provide shell access.

      GD is a little trickier to install than a Pure Perl module with no dependancies. First of all, GD depends on Math::Trig, so you would have to install that first. That is probably the smallest problem. The chances are that user 'nobody' or whatever user is used by the webserver, does not have privileges to use a c compiler. And then there is stuff like: $PREFIX = prompt('Where is libgd installed?','/usr/lib'); to catch.

      So yes, pure perl modules can easilly be installed. Modules that require compilers are a little trickier. The easiest way for sure is to ask the admin to just install it for you.


      All code is usually tested, but rarely trusted.
        I agree that if you can convince your hosting company to install the module, that's the easiest (though not necessarily the fastest) way. If that's not possible for some reason, though, installing it yourself is a workable alternative.

        With hosting companies I've used, I have never had a problem with the Web server user not having access to a compiler.

        I'm surprised that GC has manual prompts like you describe with no documented way to override them. If that's the case, you can probably work around it by sending answers to it on STDIN. I agree this is tricky, and I also find it annoying.

        export PERL_MM_USE_DEFAULT=1 gets around most Makefile.PL prompting.

      Thank you very much and I have installed the Imager module using the method you suggested. It seems to work and there is a Imager directory sitting in my home/lib..However, when I put in the

      use Imager;

      It still give me the 500 error. Do I have to call it differently if I install the module this way? Thanks.

        You need an appropriate use lib line to tell your script where to find the library. Something like:
        use lib '/path/to/your/homedir/lib/perl5';
Re: Are there ways to resize pic without using CPAN modules
by zentara (Archbishop) on Jun 17, 2005 at 16:03 UTC
    The only problem with trying to install a pre-built binary like Image Magick(or a pre-built perl xs module) to your home directory, is making sure it will match up with the c libs installed. An elf executable compiled on one linux platform will not necessarily run on another.

    I would say you would be better off doing the resizing on your local machine, and then uploading it.

    I'm not really a human, but I play one on earth. flash japh
Re: Are there ways to resize pic without using CPAN modules
by JupiterCrash (Monk) on Jun 17, 2005 at 15:46 UTC
    Without using any modules, if you could atleast get the Image::Magick binary distribution installed into your own directory, you could do a system call to the 'mogrify' utility to resize an image:

    See example usage of the 'mogrify' binary here:

Re: Are there ways to resize pic without using CPAN modules
by Anonymous Monk on Jun 17, 2005 at 12:21 UTC
    So, you have a provider that allows you to install Perl programs, but not Perl modules? Considering that you can use a module as a program, and a program as a module, that shouldn't stop you from installing a module. Or else, shell out to the tool that does the cropping. Or lift the code from a module that you want to use, and put it in your code.

    Of course, I could tell you how - but that would be in the form of another module....

Re: Are there ways to resize pic without using CPAN modules
by TedPride (Priest) on Jun 17, 2005 at 15:52 UTC
    If you don't mind batch processing the images instead of real time resizes, you could theoretically Net::FTP the images to your disk, resize them with modules installed on your own system, then Net::FTP them back.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://467657]
Approved by Corion
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-06-18 13:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.