Solved

Image::Magick crop problem

Posted on 2003-11-24
9
1,111 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

15 Experts available now in Live!

Get 1:1 Help Now