From owner-freebsd-questions Mon Apr 1 8:53:29 2002 Delivered-To: freebsd-questions@freebsd.org Received: from tninet.se (lennier.tninet.se [195.100.94.105]) by hub.freebsd.org (Postfix) with ESMTP id 9A9F937B417 for ; Mon, 1 Apr 2002 08:53:20 -0800 (PST) Received: from cs.umu.se (h16n1c1o1023.bredband.skanova.com [213.64.164.16]) by lennier.tninet.se (BMR ErlangTM/OTP 3.0) with ESMTP id 323396.679999.1017.0s16883806lennier for ; Mon, 01 Apr 2002 18:53:19 +0200 Message-ID: <3CA8907F.4DF85715@cs.umu.se> Date: Mon, 01 Apr 2002 18:53:19 +0200 From: Paul Everlund X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: sv,en MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: ImageMagick with Perl - conversion problem Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi all! A question not related to FreeBSD, but as maybe someone on the list has a solution to my problem here, I'll give it a try. People here seems to know a lot about various stuff, so that's why I'm posting it. Background ---------- I want to convert an image from some format (if it's an by me allowed format) to JPG, resize it if necessary, put a border around the image, and finally save the image in JPG- format. I've written a PERL-script that uses ImageMagick's Perl-module for this task. (I do not want to use convert.) It works ok for all images except TIFF. Error description ----------------- When converting TIFF to JPG (and even from TIFF to TIFF), the converted image shows vertical red-green-blue stripes in the image, all the way from left to right. This happens even if the image is not resized. Perl-script ----------- #!/usr/bin/perl use Image::Magick; $image = Image::Magick->new; $in = $ARGV[0]; # Image infile. $out = $ARGV[1]; # Image outfile. $w = $ARGV[2]; # Image width. $h = $ARGV[3]; # Image height. # Read the image from disk. $image->Read($in); # Check if valid image type. $type = $image->Get('magick'); if($type ne "TIFF" and $type ne "BMP" and $type ne "JPG" and $type ne "GIF" and $type ne "PNG") { print("error"); exit(1); } # Get image width and height. ($x, $y) = $image->Get('width', 'height'); # Calculate the aspect ratio. $aspectRatio = $y / $x; # Change x and y size if necessary. $sizeChanged = 0; if($x > $w) { $x = $w; $y = $x * $aspectRatio; $sizeChanged = 1; } if($y > $h) { $y = $h; $x = $y * $aspectRatio; $sizeChanged = 1; } # If the original size was wrong, then resize the image. if($sizeChanged == 1) { $image->Resize(width => $x, height => $y, filter => 'Cubic', blur => 1); } # Draw a border. $image->Border(width => 2, height => 2, fill => '#000000'); # Write the image to disk. $image->Write($out); print("ok"); exit(0); ----------------------- Any effort from anyone, trying to help me, is greatly appreciated! Thanks in advance! Best regards, Paul To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message