Image crop

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Image crop

Post by gsmnaren »

hi all,
sory for creating new topic here....
i need some script so only i created new topic....

Image

Image


very urgent i need this to done my project...
anotherprogrammer123
Posts: 36
Joined: 2010-02-21T18:02:40-07:00
Authentication code: 8675308

Re: Image crop

Post by anotherprogrammer123 »

What are you trying to do exactly?

To crop, use the Crop command in Magick++:

Code: Select all

// Crop the image to specified size (width, height, xOffset, yOffset)
    image.crop( Geometry(100,100, 100, 100) );
gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Re: Image crop

Post by gsmnaren »

i need this script : http://www.fbphotomagic.com/uploadphoto



its very urjent within 2days i need to summit my project....
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image crop

Post by fmw42 »

gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Re: Image crop

Post by gsmnaren »

ya i have try this but i didn't understat...
can u plz do like that...
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Image crop

Post by Bonzo »

This should get you started:

Code: Select all

<?php
// If the form has been submitted do this
if ( isset( $_POST['Submit'] ) ){

// Temporary upload image name
$original_image = $_FILES['filename']['tmp_name'];

// Name to save the image as - in this case the same as the original
$new_image = $_FILES['filename']['name'];

$size = getimagesize ($original_image);
// crop out the images and save

$cmd = "$original_image -gravity northwest".
" ( +clone -crop 100x200+20+125 -write 1.jpg +delete ) ".
" ( +clone -crop 100x40+140+205 -write 2.jpg +delete ) ".
" ( +clone -crop 100x40+250+205 -write 3.jpg +delete ) ".
" ( +clone -crop 100x40+360+205 -write 4.jpg +delete ) ".
" -crop 100x40+470+220 5.jpg ";

exec("convert $cmd "); 

$cmd = " -size {$size[0]}x{$size[1]} xc:white".
" 1.jpg -geometry +20+125 -composite ".
" 2.jpg -geometry +140+205  -composite ".
" 3.jpg -geometry +250+205 -composite ".
" 4.jpg -geometry +360+205 -composite ".
" 5.jpg -geometry +470+205 -composite +repage";

exec("convert $cmd $new_image"); 

echo "File uploaded<br>";

}
else { ?>
<p>File to upload:</p>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> 
<input type="file" name="filename"  />
<input type="Submit" name="Submit" value="Submit" />
</form>
<?php }; ?>
gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Re: Image crop

Post by gsmnaren »

Warning: exec() has been disabled for security reasons in /www/99k.org/s/t/e/XXXXX/htdocs/Profile Design/main page/upload.php on line 21

Warning: exec() has been disabled for security reasons in /www/99k.org/s/t/e/XXXXX/htdocs/Profile Design/main page/upload.php on line 30
File uploaded
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Image crop

Post by Bonzo »

How did you intend on running the code as you may be able to use Imagick which does not use exec( ) or Magickwand for php but I do not use them and so can not do an example.

If you want to use exec( ) you will either have to ask the hosts to allow it and confirm safe mode is off or change hosts.

Mistake in the code anyway as I forgot to escape the ( ) for linux.

Code: Select all

<?php
// If the form has been submitted do this
if ( isset( $_POST['Submit'] ) ){

// Temporary upload image name
$original_image = $_FILES['filename']['tmp_name'];

// Name to save the image as - in this case the same as the original
$new_image = $_FILES['filename']['name'];

$size = getimagesize ($original_image);
// crop out the images and save

$cmd = "$original_image -gravity northwest".
" \( +clone -crop 100x200+20+125 -write 1.jpg +delete \) ".
" \( +clone -crop 100x40+140+205 -write 2.jpg +delete \) ".
" \( +clone -crop 100x40+250+205 -write 3.jpg +delete \) ".
" \( +clone -crop 100x40+360+205 -write 4.jpg +delete \) ".
" -crop 100x40+470+220 5.jpg ";

exec("convert $cmd "); 

$cmd = " -size {$size[0]}x{$size[1]} xc:white".
" 1.jpg -geometry +20+125 -composite ".
" 2.jpg -geometry +140+205  -composite ".
" 3.jpg -geometry +250+205 -composite ".
" 4.jpg -geometry +360+205 -composite ".
" 5.jpg -geometry +470+205 -composite +repage";

exec("convert $cmd $new_image"); 

echo "File uploaded<br>";

}
else { ?>
<p>File to upload:</p>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> 
<input type="file" name="filename"  />
<input type="Submit" name="Submit" value="Submit" />
</form>
<?php }; ?>
gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Re: Image crop

Post by gsmnaren »

no also same error bro.....
add me in skype tool ID : rptnaren
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Image crop

Post by Bonzo »

I am afraid I do not use Skype or any chat programs and as I said if you want to use my php method you need to get exec( ) allowed and safe mode turned off.
There is system( ) and passthru( ) but I assume that if exec( ) is turned off they will be as well - exec is the prefered method.

There is Imagick which does not use exec( ) but you need to have that installed and I do not use it so you would need to work out your own code. It is not very well documented.
The php page for it is: http://php.net/manual/en/book.imagick.php
I think this is the guy who is writing Imagick: http://valokuva.org/?cat=1

I do not know how to run Freds scripts on the server without php but that is a possiblity if you can do that.
gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Re: Image crop

Post by gsmnaren »

can u create like this for fbml script
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Image crop

Post by Bonzo »

can u create like this for fbml script
I can not but somebody may be able to - probably not here - but you could create another thread about that.
gsmnaren
Posts: 7
Joined: 2011-01-02T06:46:35-07:00
Authentication code: 8675308

Re: Image crop

Post by gsmnaren »

where i can create a new topic
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image crop

Post by fmw42 »

click Developers at the top of the page ( or Return To Developers at the bottom of this page) and then click New Topic button.
userman
Posts: 12
Joined: 2010-09-12T10:58:46-07:00
Authentication code: 8675308

Re: Image crop

Post by userman »

Hi bonzo,

thanks, you script work for me!!! great work!!!

Can you recommend to me a script for modify the area crop? http://www.hotscripts.com/blog/javascri ... g-scripts/
how can i select diferent area with the javascript image cropping scripts?

Regards.
Post Reply