Page 1 of 2
Image crop
Posted: 2011-01-02T07:11:58-07:00
by gsmnaren
hi all,
sory for creating new topic here....
i need some script so only i created new topic....
very urgent i need this to done my project...
Re: Image crop
Posted: 2011-01-02T08:37:06-07:00
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) );
Re: Image crop
Posted: 2011-01-02T21:25:53-07:00
by gsmnaren
i need this script :
http://www.fbphotomagic.com/uploadphoto
its very urjent within 2days i need to summit my project....
Re: Image crop
Posted: 2011-01-02T21:38:46-07:00
by fmw42
Re: Image crop
Posted: 2011-01-02T21:57:35-07:00
by gsmnaren
ya i have try this but i didn't understat...
can u plz do like that...
Re: Image crop
Posted: 2011-01-03T03:27:59-07:00
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 }; ?>
Re: Image crop
Posted: 2011-01-03T04:35:25-07:00
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
Re: Image crop
Posted: 2011-01-03T05:07:10-07:00
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 }; ?>
Re: Image crop
Posted: 2011-01-03T05:13:42-07:00
by gsmnaren
no also same error bro.....
add me in skype tool ID : rptnaren
Re: Image crop
Posted: 2011-01-03T06:04:53-07:00
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.
Re: Image crop
Posted: 2011-01-03T06:45:14-07:00
by gsmnaren
can u create like this for fbml script
Re: Image crop
Posted: 2011-01-03T06:57:02-07:00
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.
Re: Image crop
Posted: 2011-01-03T21:46:21-07:00
by gsmnaren
where i can create a new topic
Re: Image crop
Posted: 2011-01-03T21:49:07-07:00
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.
Re: Image crop
Posted: 2011-01-26T05:07:34-07:00
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.