Total downloads: 20947
Category: Flash PHP
File last revision: 07, Oct 2003 08:10:44
License: LGPL
a simple integration of Flash and PHP to build an image cropping tool. Upload your photo, then create a cropping mask under Flash and when you click on save PHP will create a new image based on te cropping mask you created.
Note that this tool requires Flash and PHP with GD libraries installed to work
P.S. before install read the readme.first text document inside the rar file.
Flash content
Comments (64)
FDlash can't handle progressive jpg... So maybe you should write it somewhere...
What you people should do again, is look at the ImageMagick module. Heres the sollution for the PHP page loaded when you have completed the flash crop :
CreateCrop("Path to original file", "Path to cropped destination", $x2, $y2, $x1, $y1, "Path to mogrify");
function CreateCrop ($sw_ct_path, $sw_ctt_path, $x1, $y1, $x2, $y2, $mogrifypath) {
@unlink("$sw_ctt_path"); // Remove file and prevent warning
if (!copy($sw_ct_path, $sw_ctt_path)) {
ErrorReport('Could not duplicate the image file for thumbnail creation!');
}
if(CropImage($sw_ctt_path, $x1, $y1, $x2, $y2, $mogrifypath)) { return 1; } else { return 0; }
}
function CropImage ($sw_ri_path, $x1, $y1, $x2, $y2, $mogrifypath, $sharpen=0) {
global $debug;
if($debug){ echo "<br><b>function CropImage</b><br>"; }
$currentimagesize = getimagesize($sw_ri_path);
$image_width = $currentimagesize[0];
$image_height= $currentimagesize[1];
// Need to insert size error checking if crop is larger than the accuall image.
$cmd = "$mogrifypath -crop ".$x1."x".$y1."+".$x2."+".$y2." ".
"$sw_ri_path 2>&1";
if($debug)echo $cmd . "<br>";
exec($cmd, $exec_output, $exec_retval);
if($exec_retval > 0) {
if($debug) { echo "ERROR: exec() error: $exec_output[0]"; }
return 1;
} else {
if($debug){
print "Image was cropped.<br>"; }
return 0;
}
}
I still use GD 1.6 si I can't help you.. but if you find a way pls tell us
My server has GD 2.0 so I changed
imagecopyresized($dst_img, $src_img, 0, 0, $x1, $y1, 100, 100, $x2, $y2)
to
ImageCopyResampled($dst_img, $src_img, 0, 0, $x1, $y1, 100, 100, $x2, $y2)
first one works good but second one always start cropping from top left corner of the source image insted of "x1,y1"
any help?
Great tool! Still version 0.1 so can really
complain here, :)
The "Error, images MUST be valid" problem appears
to be in Opera browsers. To fix this
(And get the error in IE instead.. huh..
Open "index.php" and alter line 15 from :
if($img['type'] != "image/pjpeg" || $type != 2)
to
if($img['type'] != "image/jpeg" || $type != 2)
For starters I also wouldnt get the GD thingie to
work on my server, though I have latest GD installed.
In the "imageCrop.php" file however, I solved this
in the variabel :
$ext = "png";
alter to JPG mode
$ext = "jpg";
Remember that you get a download box, since the force
download script is activated here and the cropped image
is downloaded.
However, compared with GD, I think ImageMagick is the
better sollution here to combine, gives a much more
slick result that GD and it opens up alot of more
possibilities.
I take my hat of for you sephiroth!
sorry about my last comment, my winrar was damaged.
this site is very intresting for me
the .rar file is wrong
"Error, images MUST be valid jpg"
Tried about 20 images. Get this every time :-(
You know if this work fine in Mac OS X ?
