Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm going to add a bit of explanation about why I'm in this bind before getting into the problem.

I'm working at a place where perl is being phased out - but oh so slowly. The reasons for it are many, and I won't go into it here. However, because it's being phased out, there's been no real drive to upgrade perl, and it's difficult at best to get support for newish things.

Having said that, I'm using perl 5.005_02 on redhat 6-2, and I cannot upgrade it. It's also going to be a next to impossible task to do what I really want to do, and install Image::Magick.

I'm stuck using GD (it's already installed) to resize an image, so quick test code looks like this:
open (TMP, ">/tmp/test.jpg"); my $file = upload('thefile'); my $image = GD::Image->newFromJpeg($file); my ($x, $y) = $image->getBounds(); my $new_image = new GD::Image(800, 600); $new_image->copyResized($image, 0, 0, 0, 0, 800, 600, $image->getB +ounds); binmode(TMP); print TMP $new_image->jpeg;
Which seems to be working fine-ish, it's creating 800x600 images for sure, but there is a drastic loss of image quality. And I don't mean the standard blockiness etc, I mean like a complete loss of color, so all I see are vague outlines of an image. This obviously is not acceptable, so, I'm trying desperately to discover why it's doing this.

The question is, has anybody run into this problem before? Why such a massive loss of quality? Secondly, are there any other potential modules that I can use other than Image::Magick (which rely's on drivers/software not currently installed on the redhat 6.2 boxes) and/or GD to perform this task? Or am I stuck going to bat to try and get ImageMagick installed?

--

On a semi related note, the *real* reason that I'm attempting to do this is so that all the image manipulation etc can happen "in memory". We've been running into a problem with a script that does this all by creating files on the machine, running a command on them, and then uploading the new file elsewhere. There are a lot of 0 byte files being created, and I suspect either NFS, or our clustering, or disk space as being the root cause. Has anybody run into the 0 byte problem before when accepting file uploads using an old version of CGI?

Note that the open & print to TMP is not actually necessary, nor will it be like this in the production code, this is just for me to view the images so I can run some tests. In actuality the file will be inserted into a BLOB in the database, hence the idea that we do this all without creating temp files...

In reply to GD loss of quality by the_slycer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-29 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found