Solved

Image::Magick crop problem

Posted on 2003-11-24
9
1,119 Views
Last Modified: 2010-07-27
Hi there:

I'm tryingto crop an image with Image::Magick but not at the TopLeft position. I'm ussing this:

#!/usr/bin/perl
use Image::Magick;

my $imImage = Image::Magick->new;
$imImage->Read("try.gif");
$imImage->Crop(geometry=>"50x20+40+60");
print "Content-type: image/gif\n\n" . $imImage->ImageToBlob(magick=>'gif');

But what I get is an image like this:

|<----------- 90 ----------------->|
              |<------- 50 ------->|

+----------------------------------+ -  
|                                  | ^
|    TRANSPARENT                   | |
|                                  | |
|                                  | |
|             +--------------------+ 80 -
|             |                    | |  ^
|             |   DESIRED CROPPED  | |  |
|             |                    | |  20
|             |       IMAGE        | |  |
|             |                    | v  v
+-------------+--------------------+ -  -

What's wrong with this?

xabi

PS:

- If I use print "Content-type: image/png\n\n" . $imImage->ImageToBlob(magick=>'PNG'); seems to work.
- Explorer renders the cropped image well, but mozilla no.
0
Comment
Question by:xabi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Author Comment

by:xabi
ID: 9809644
Sorry but proportional font doesn't show the table OK. Just C&P on any text editor (Ultraedit, textpad, vi, emacs, etc)

xabi
0
 
LVL 10

Expert Comment

by:rj2
ID: 9811542
Does it help if you add statement below before first print?
binmode(STDOUT);
0
 
LVL 8

Author Comment

by:xabi
ID: 9811673
That's not the problem.

I also did:

print "Content-type: image/gif\n\n";
binmode STDOUT;
$imImage->Write('gif:-');

with the same results.

xabi
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:rj2
ID: 9811701
Does the problem only occur in Mozilla? It seems to work alright with gif in IE
Is the problem that image don't get cropped, but is displayed as same size as before with the parts that should be cropped as transparent?
0
 
LVL 8

Author Comment

by:xabi
ID: 9811725
well, In mozilla image isn't displayed right. Anyway I don't want this crop to use with mozilla, but to use it with cellular phones.
With the cells it down't works (but ericsson).

xabi
0
 
LVL 10

Expert Comment

by:rj2
ID: 9813119
>With the cells it down't works (but ericsson).
I don't understand your statement above. What does works and what does not work? What happens when it does not work?
0
 
LVL 8

Author Comment

by:xabi
ID: 9816325
This is the Image I get from the script above:

http://xa.bi/files/cropped.gif

and the original is:

http://xa.bi/files/try.gif

xabi

Try the result image in mozilla and in Explorer. In a cellular phone i get the same result as Mozilla.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10093671
Nothing has happened on this question in more than 6 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
PAQ, refund points (a little progress, but ultimately unanswered).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10148153
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl script help 12 107
perl script to count sepecial characters in a file 7 148
how to print sub line with  sed /awk /perl in bash file 11 69
Merging two files with Perl 5 32
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question