Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Creating thumbnail solution help

by uG (Scribe)
on Mar 05, 2010 at 21:22 UTC ( #827069=perlquestion: print w/ replies, xml ) Need Help??
uG has asked for the wisdom of the Perl Monks concerning the following question:

I am using Imager to dynamically create thumbnails of jpegs. However when some images are resized it adds blocks of transparent colors over it, or even cuts off complete pieces of the images. Some images it won't even resize, which it is telling me 'Couldn't render image: Bogus DQT index 11'. But I can still view the images in photoshop, web browsers, etc.

Is this a problem with Imager or with the jpeg library it uses?

I would just use image magick to permanently create the thumbnails as they are uploaded, except every time I try to install it via cpan it errors asking for me to insert a disk (wtf?), and ppm doesn't have Catalyst::Plugin::Upload::Image::Magick::Thumbnail. ImageMagick has just been a giant pain in the ass on win32 and i'd like to avoid it.

Anyone have any ideas on the Imager problem, or any other solution I could implement? I am developing on win32 using strawberry perl 5.10.

Comment on Creating thumbnail solution help
Re: Creating thumbnail solution help
by almut (Canon) on Mar 05, 2010 at 21:34 UTC

    Are you sure you're handling your image data always in binary mode?  For example, reading them in in text mode might well produce broken images.  Just a guess, though...

Re: Creating thumbnail solution help
by tonyc (Pilgrim) on Mar 05, 2010 at 22:36 UTC
    Posting the code you're using and a link to one of the problematic images would be useful.
      Here is an image: http://img707.imageshack.us/img707/2011/picture066q.jpg The code im using is
      sub thumbnail :Regex('^thumbnail/(.+)') { my ($self, $c) = @_; my $image_id = $c->req->captures->[0]; $image_id =~ s/\//\\/g; my $image_obj = $c->model('File')->slurp($image_id) or $c->detach('/default'); $c->stash->{scaling} = 'fit'; $c->stash->{x} = 100; $c->stash->{image} = $image_obj; $c->forward('View::Thumbnail'); }
      It can also be seen on the author's site here: http://perl.jonallen.info/writing/articles/creating-thumbnails-with-catalyst It opens the file using Catalyst::Model::File. I don't see any parameters to set it to binary, so maybe that is why. But the tutorial on the author's page above doesn't mention anything about having to set the file model to binary so I dunno...
        It is indeed a problem with Imager or the jpeg library it uses. I don't know if its only on a windows platform or not though. Instead i've wrote a catalyst view that uses Image::Resizer instead of Catalyst::View::Thumbnail which uses Imager.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://827069]
Approved by jrsimmon
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (18)
As of 2014-07-31 14:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls