Need an image resize script made in CGI Pearl

Posted on 2008-11-05
Last Modified: 2013-12-25

Do anyone have a simple image resize script made in CGI pearl that can resize images without loosing its quality?
Question by:Gurbirs
    LVL 39

    Accepted Solution

    When you resize an image smaller, you are removing pixels, so it will lose quality.  If you make it bigger, you are adding pixels, and the colors for those pixels has to be made up somehow.  This sometimes causes pixelation, but some resize algorithms are better than others.

    Anyway, you can use the Image::Resize.  
    use strict;
    use CGI ':standard';
    use Image::Resize;
    my $image = Image::Resize->new('large.jpg');
    my $gd = $image->resize(250, 250);
    open(my $out, ">Small.jpg") or die "Couldn't open/write: $!\n";
    print $out $gd->jpeg();
    print header();
    print "<html><body>Success!</body></html>\n";

    Open in new window


    Expert Comment

    so this doesn't use GD or any other library?

    This is now in Perl? and this works in gif and png?
    LVL 39

    Expert Comment

    bs98909 - This really should be a new question.  But a quick answer here: It uses the GD library.  Documentation is available here:
    If you have follow-up questions, please start a new question.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now