in reply to Re^4: Image::Thumbnail work under windows but not on linux
in thread Image::Thumbnail work under windows but not on linux

The documentation for Image::Thumbnail shows the following usage:

use Image::Thumbnail 0.65; # Create a thumbnail from 'test.jpg' as 'test_t.jpg' # using ImageMagick, Imager, GD or Image::Epeg. my $t = new Image::Thumbnail( size => 55, create => 1, input => 'test.jpg', outputpath => 'test_t.jpg', ); # Create four more of ever-larger sizes for (1..4){ $t->{size} = 55+(10*$_); $t->create; }

I don't see any call to ->create in your code. Did you forget that call?

Update: Now I see - create => 1 is supposed to automatically create the thumbnail. If you use the automatic way, you won't get access to the error diagnostics, so I would look at the manual way first, to see the potential error messages:

my $t = new Image::Thumbnail( size => 55, create => 1, input => 'test.jpg', outputpath => 'test_t.jpg', ); $t->create; print "Errors : " . $t->{error, "\n"; print "Warnings:" . $t->{warning}, "\n";

Upon reading the source code, it seems as the module does not actually set up those fields in most situations.

Replies are listed 'Best First'.
Re^6: Image::Thumbnail work under windows but not on linux
by *alexandre* (Scribe) on Aug 14, 2019 at 11:52 UTC
    Solved by using module Imager within this code
    #!/usr/bin/perl use warnings; use strict; use Image::Thumbnail; my $imgdir= "/var/www/upload"; createImageMagickThumb('testFileUploadAndThumb.jpg'); sub createImageMagickThumb { my $filename = shift || ''; print "file name : $filename\n"; print "file directory $imgdir\n"; my $t = new Image::Thumbnail( module => 'Imager', create => 1, size => 100, input => "$imgdir/$filename", outputpath => "$imgdir/thumb.$filename", ); print "input => $imgdir/$filename\n"; print "outputpath => $imgdir/thumb.$filename\n"; }