cropping problems

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
jammyjames

cropping problems

Post by jammyjames »

Hi,

I found this forum in a frantic rush to try and finally solve the problem I have.

I am trying to crop an image using Imagemagick: http://pastebin.com/1ZKgHWLk

The code I have written to do this: http://pastebin.com/Cr7qDj3J does everything & crops the image BUT it outputs a black image.

I have tried everything to try and resolve. Im sure it's something simple BUT I can't figure out what it is.

Does anyone have any ideas?

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: cropping problems

Post by fmw42 »

Perhaps you need to remove the virtual canvas after cropping. See http://us3.php.net/manual/en/function.i ... gepage.php
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: cropping problems

Post by el_supremo »

If I read it correctly, you aren't loading the image into memory. load_image only pings the image. You should use _load_image

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
jammyjames

Re: cropping problems

Post by jammyjames »

Thanks guys for replying.

Pete, I thought the same and tried _load_image but when I do use this it throws an error: Resource Id: ... does not exist

Any ideas? The absolute file path it references does seem to be correct.

Thanks for your help.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: cropping problems

Post by Bonzo »

Start simple, get it working and then add all the posts etc.

Code: Select all

<?php

$im = new imagick( "input.jpg" );
 
$im->cropImage( 100, 100, 50, 50 );
 
$im->writeImage( "thumbnail.jpg" );
?> 
	
<img src="th_80x80_test.png">
jammyjames

Re: cropping problems

Post by jammyjames »

Thanks

I don't know what I decided to use a custom class.

The code you offered is fine. A problem out the way.
Thanks again.
Post Reply