Solved

Image::Magick crop problem

Posted on 2003-11-24
9
1,114 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now