Jump to content

Image Cropping


dustinto

Recommended Posts

I want to make a program that will be able to take an image file and crop a square at a given coordinate value (X,Y).

I would tell it the X,Y and the size of the crop ie. 350x350. The X,Y would be the center of the newly created image.

I'm sure this can be done but I get a little lost when looking at all the different documents on how to go about doing this. Hopefully someone here can help me out.

Thanks for you help
Link to comment
Share on other sites

SOmething like this

Save in ::crop.php ::
[code]<?php
$file = $_GET['file'];
$x = $_GET[x];
$y = $_GET['y'];

$src = imagecreatefromjpeg($file);
$dst = imagecreatetruecolor(350, 350);

imagecopyresized($dst,$src,0,0,$x-175,$y-175,350,350,350,350);

imagejpeg($dst);
imagedestroy($dst);
imagedestroy($src);
?>[/code]

Place on page with
[code]<IMG src='crop.php?file=myimage.jpg&x=500&y=500' width='350' height='350'>[/code]
Link to comment
Share on other sites

You need to install GD 2.0
Don't worry this is very easy. You can look for instructions on the official page. Don't have it right now, but you can google it.

Basicly,

You find the code snip in php.ini.recommend and unmark it. <- forget the actuall word describing the action

so it will look like this -> extension=php_gd2.dll
instead of -> ;extension=php_gd2.dll


Jay
Link to comment
Share on other sites

I got that installed and it worked great. Thanks

Now is their some way I could make the image transparent?

I want to display two images that will be cropped using the above tool and then have a third one that will be the two images on top of each other with one being transparent.

Thanks
Link to comment
Share on other sites

Thanks I got that both of those working.

I had to set the script to save the newly cropped images before making them transparent, because it would crash the server if I tried to crop and make them transparent in one action. Guess since the files are so big.


I do have another question.

Do you happen to know if there is anyway to draw a box on the image and save it. It would be used to highlight an area...would be a nice feature, but I can do that manually if it can't be done.

After cropping 230 of these manaully last week (in powerpoint - 70 slides) I would like to make as much of the process automated as I can. Since we are going to be using this process on all new jobs :(
Link to comment
Share on other sites

[!--quoteo(post=384149:date=Jun 15 2006, 12:31 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Jun 15 2006, 12:31 PM) [snapback]384149[/snapback][/div][div class=\'quotemain\'][!--quotec--]
imagerectangle()
[/quote]

I found the command, but I wasn't sure of some way to physically click on the image and make the rectangle. Maybe with javascript
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.