Re: Wx::Perl::Imagick
Steve Cookson - gmail <[email protected]> Tue, 20 Jan 2015 08:02:06 -0300
| Newsgroups | gmane.comp.lang.perl.wxperl |
|---|---|
| Message-ID | <[email protected]> |
Hi Garu, I haven't seen you since the SP YAPC. I hope you are well. We have all returned to the UK now. That Wx::Perl::Imagick advice was very nicely done. Good luck, Regards Steve. On 18/01/15 22:49, breno wrote: > On Sun, Jan 18, 2015 at 6:47 PM, Daniel <[email protected] > <mailto:[email protected]>> wrote: > > > @Garu: I tried to follow the steps under WARNING and that didn't > work, thats why I was writing this call for help... > > > Hi Daniel, > > your problem doesn't seem to be with Wx, but with ImageMagick (the > external library), and I think you should concentrate your efforts in > "how to install ImageMagick on Windows 7", and only then you should > worry about the Image::Magick Perl module (and only after that with > Wx::Perl::Imagick, if at all). > > When you say "that didn't work", what do you mean? Which step of that > tutorial failed? How did it fail? Are there any error messages we can > look at in order to help you out? > > I've tried expanding the original tutorial below, hopefully it helps: > > 1. figure out whether your Citrus perl is 32 or 64 bits (you should be > able to tell from the output of "perl -V") > 2. figure out whether your Win7 is 32 or 64 bit => > http://pcsupport.about.com/od/windows7/ht/windows-7-32-bit-64-bit.htm > 3. Make sure both Citrus perl and ImageMagick match your systems, > whether it's 32 or 64 bits > 4. download the appropriate binary for ImageMagick: > - 64-bit Win7: > http://www.imagemagick.org/download/binaries/ImageMagick-6.9.0-4-Q8-x64-dll.exe > - 32-bit Win7: > http://www.imagemagick.org/download/binaries/ImageMagick-6.9.0-4-Q16-x86-dll.exe > 5. Run the file you just downloaded and follow the installation wizard. > - ***make sure*** the Wizard installs the development files > (libraries+headers) > 6. after the installation is complete, go to the command line and > type: "convert logo: logo.gif" (without quotes) to make sure it's > installed successfully; > 7. if everything went ok, try and install Image::Magick from CPAN one > more time. > > If you have more trouble, I advise you go to ImageMagick's public > forum at http://www.imagemagick.org/discourse-server/ as it doesn't > look like a Wx issue - or even a Citrus Perl issue for that matter. > > That said, you did mention afterwards that all you want to do is > resize an image and save it to disk. Well, Citrus Perl should have > come with the GD module, which can (amongst several other things) do > just that. Granted, I'm not very familiar with GD so I could be waaaay > wrong here, but from their documentation the code below should work > (note: I just wrote it on the email body, code might have typos and is > not really tested): > > ----------------8<---------------- > use strict; > use warnings; > use GD::Image; > > # note: newFromJpeg() and newFromGif() are also available > my $source_image = GD::Image->newFromPng( "/path/to/file.png" ); > > my ($source_width, $source_height) = $source_image->getBounds; > > my $target_width = 100; # pixels > my $target_height = 100; #pixels > > my $target_image = GD::Image->new( $target_width, $target_height ); > > # resize our $source_image into $target_image > $target_image->copyResized( > $source_image, > 0, 0, # target_x, target_y > 0, 0, # source_x, source_y > $target_width, $target_height, > $source_width, $source_height > ); > > # saved resized file to disk > open my $fh, '>', '/path/to/resized.png' > or die "error opening resized.png for writing: $!"; > > binmode $fh; > print $fh $image->png; > close $fh; > ---------------->8---------------- > > Hope it helps! > > Good luck, > > garu >