silverorange labs

Comments

Comments are locked. No additional comments may be posted.

Peter Rukavina -

Wonderful move.

Peter Rukavina -

<P>
Just by way of elaborating a point I mentioned around here somewhere last week: we ran a test over several weeks of visitors to the website of a client of Reinvented. For every visitor to the home page of the site, we used Macromedia's own JavaScript code for testing the presence of a Flash player, and we logged every result, with the client's IP address.

The results showed that only <B>5% of clients had Flash installed</B>. The stands in great contrast to Macromedia's own statistics that seem to suggest 98.4% of web users can "view Macromedia Flash content."

Either our testing is under-reporting Flash-enabled browsers, or there isn't as much Flash around as we think.

TheChillPill -

In relation to your Java tool, do you have any plans to release that? I know you guys had that working with Coldfusion and I recall a lengthy discussion online somewhere about it.

I for one would certainly appreciate having a play around with it in the interests of advancement.

Steven Garrity -

TheChillPill, we'll see if we can get the Java version released too.

TheChillPill -

Thanks Steven =)

Paul Scrivens -

Too sweet man. Too sweet.

Nick Burka -

A glitch with the coordinates passed back when the crop box was flipped over has been fixed.

Gayle -

I downloaded the source code and uploaded to my server to try (I'm not really a script person but trying to learn..) When I opne the index.php in my browser, I get a message please wait while the image loads then nothing..
any ideas? server is running apache

Nick Burka -

Gayle, I've double checked that the source code in the zip file is correct and I believe it is. You should be able to just download it and run it.

One thing I should have mentioned in the original post is that this does require having the GD library installed with PHP. It uses several of the php image functions which use the GD Graphics Library.

Gayle -

Ok..I'll try again..
Thanks..:)

Gayle -

Ok..uploaded a new set of files..
still the same thing
It makes a tmpimage1.jpg in the script folder on the server but is stuck at please wait while the image loads..
http://www.redhotgalleries.com/cropper/
weird, huh?
any ideas?
Thanks
Gayle

Nick Burka -

chillpill, as you might have noticed in <a href="archives/2003/october/javacropper">a recent post</a> we've uploaded our older Java applet photo cropper. Check it out, works pretty well too. It's packaged in the updated zip file above.

TheChillPill -

Thanks Nick, much appreciated :-)

jake -

I'm not sure if this is the problem you're talking about, but in the text file, the second problem you had...

pixel specific things. The reason I question the problem is this is what happens with pixel fonts, I assume it's the same for graphics. When bringing the file onto the "stage" make sure it's dimensions and it's coordinates are "to the pixel." ie. put the 135x30 image at 10x100 not 10.5x100.7

I hope this helps. :)

MC -

Just as a side note to the ChillPill - I downloaded the Flash version today and tried it out with the same effect he reported. It displays the "please wait" message, creates a temporary file, and hangs.

This is on PHP 4.3.3, with GD installed.

Any clues?

MC -

After some additional tinkering, I've found that setting the $tmpdir variable in CropImage.php is what breaks the script. When you set the temporary directory, it won't find the temporary image, and therefore won't proceed to display the cropping tool.

I'm using a full path for this variable (e.g. /home/accntname/temp/).

If I omit this variable and set the permissions on the directory where the main php script is, it all runs fine.

garoo -

For what it's worth: sometimes I, too, get the neverending "Please wait" thing. It seems to happen with some (or maybe all) progressive jpegs, and converting them to temporary non-progressive jpegs with a couple of PHP lines solves the problem.

dan -

god damn ive been looking for this script for days and yours is exactly what i wanted, keep up the good work :)

Brian Woods -

Hey, I can't seem to get the java applet to load. 2 things. There was a bug in CropImage.php. It couldn't find the function HTML_hidden.

Now that is fixed IE won't load the applet even though it ends up in my file cache. When I use the java applet from your site 3 classes are loaded into my cache (CropBox and CropHandle as well as CropImage). When I run it on my site only CropImage goes into my cache.

Any ideas? Thanks. Great work.

Brian Woods -

Er...I meant CropApplet not CropImage. Sorry. :)

matte -

Is it meant to restrict the shape of the crop box? I can only uniformly resize the box. I can't, say, make it letterbox shaped.

??

(e)

Steven Garrity -

matte, yes, the box is intentionally help to a square aspect ratio - this was what we needed.

Derek Scruggs -

Re: the tempdir problem: it looks like you really need two variables. One is the filesystem path, which is used in the copy() function on line 239 of CropImage.php. In the <Object> code, $this->tmpdir needs to be a url path. The quickest workaround is to set $this->tmpdir to the correct filesytem path for the temp file on line 239, then reset it to the url path right after the copy().

Derek Scruggs -

Hmmm... In my tests, I can't seem to get it to post the crop params. The generated "<PARAM NAME=movie VALUE=" includes "&hiddenFields=process=1", but the $_POST array is always empty...

Derek Scruggs -

Sorry about that. What I was trying to say...

The Flash applet is not properly formatting the request as a POST, so the $_POST array is always empty. I used Proxytrace and verified that it's only sending GET, not POST. Any idea why that might be?

PS This is using the default configuration exactly as downloaded.

Batch -

I am also having problems with "progressive" and "non-progressive" jpegs, as garoo mentioned. He said it can be solved with a couple of extra lines of PHP - can you share those with us please? I imagine it's imageinterlace, but am not totally sure where or how to use this...

Batch -

I can't seem to get gifs displaying at all in the movie, am I doing something wrong or is this file type not supported?

Michael Sinclair -

Excellent utility. One quick note, however, is that with short tags disabled, the script becomes broken. Easy to fix with a quick replace of `<?=` with `<?php echo`.

Also --- Currently trying to add PNG support. Anyone else tried and succeeded in this? After making the proper filetype modifications (just testing it with PNG only), it sits there without actually loading the image. Works perfectly with JPEG's, however.

Thanks in advance for any replies. :)

Michael Sinclair -

Hmm... it ate my last message. Basically said a quick replace of `<?=` with `<php echo`, in case anyone needed fix.

Michael Sinclair -

Oh yeah, Flash doesn't natively support importing anything but JPEG's at runtime, sadly.

Nick Berry -

Any way to change the aspect ratio of the crop box?

I love this tool, I just need to be able to have control over my selection area!

fred -

Hi,

1) How to do to add a 'rotate image' capability on the flash component ?
2) How to do to have a free selection control ? (square fo instance)
Thanks a lot
regards

Wei Wu -

When I download the Source Code (version 1.2) and run it.
It shows the error message:
"Call to undefined function: imagecreatefromjpeg() in CropImage.php"

In [CropImage.php] there have 2 function which call imagecreatefromjpeg() and imageCreateTrueColor() are not defined??

john -

try to use this too and am getting "Call to undefined function: imagecreatefromjpeg() in CropImage.php"

Nick Burka -

For those of you who are getting the "Call to undefined function: <a href="
http://www.php.net/imagecreatefromjpeg">imagecreatefromjpeg()</a> in CropImage.php"
error, you likely don't have the GD Graphics library installed. See the PHP website for information.

Arpit -

dude, first of all, hats off to ya, im impressed, i had a rookie question (i dont mess around with gd lib too much), how would i go about adding a minimum image size clause (just like how you have max size) i would like min size for the cropped image ?

any help of pointing in the right direction would be appreciated,

arpit

Zafer Kotan -

DOTNET CROP IMAGE pls

Pablo Impallari -

If you cant see the croped result,
maybe is not that te script its not working...
maybe its only a permisions problem.

In the CropImage.php file
Try putting this line as a comment:
chmod($destinationfile,0660);

just like this:
// chmod($destinationfile,0660);

It works for me...

Bye.. and congrats for the great work.

Pablo Impallari. Php coder from argentina...

Pablo Impallari -

PD: if you have run the script just once before doing that...
yo will have to go back and reset te folder permison to, to 777 for example.

Sorry about my little english...

Bye...
Pablo Impallari

P.Sunil -

Hi, i have been working on a very similar script on my own for one of our client. One strange requirement made me look for similar work on web and i got here.

What i built was :

Step 1: User uploads any image of his choice.

Step 2: image gets scaled to proportion below (775x580) & loads in the flash cropper tool

step 3: user could use the cropper to select the image portion that he needs. User can see a live preview of the same below the actual full scale image view.

Step 4. user presses crop button beneath to save the selected/cropped portion as a new jpg image.

You can check the basic version of the app at this location : http://www.nliven.co.in/demo/flash/others/cropper/crop.html

You can start the upload part from :

http://www.nliven.co.in/demo/flash/others/cropper/upload.php

Now here is where i am stuck. Our client wants the output image size to match proportions that are passed during the upload page itself(this will be on clients actual website). So the cropper cant be reduced to a size below that but it can be increased to a size above that. But, the live preview at the bottom would only be the exact size of the passed output image parameters. For example, if output image size was 200x200, cropper cant be reduced to a size below 200x200 but can be increased further to any size below 775x595(that mc's proportions). but the live preview window at all times stays 200x200 scaling down any selection made by the user above to match to fit this size in realtime.

Would very much appreciate any ideas/help on this. Can this cropping tool be tweaked to make this work?

Cheers

crockett -

Nice tool, hope to put it to good use in the future.. Thanks for sharing.

Ramin -

Thank you for the tool. I made an addon from it for Pixelpost's next version (pixelpost.org).

thanks!

Glenn Gasner -

When I freshly installed this to my Apache/Linux server I got this error the first time I pulled up index.php:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 7040 bytes) in /photocrop/classes/CropImage.php on line 234

It turns out the imageCreateFromJPEG() function needs a lot of memory to run.

I was able to solve this problem by putting this line:

ini_set("memory_limit","19148K");

at the beginning of the CropImage.php file. I was told that if that didn't work that I would've needed to beg my host to allow me to use 16M of RAM instead of the, apparently, 8M I was currently allowed to use.

PS. SilverOrange totally rocks for making this available to everyone!

Glenn Gasner -

As far as security for this application goes, are there any real Flash/php geeks out there who can spell out what they think would need to be done to make this application secure for random internet users to use on my site? Would it just take tweaking one or two things, or is it a massive project that I shouldn't even bother with?

Glenn Gasner -

I'm not sure how to include this without copying the whole index.php file. This is how I've modified it enough so that:

A) It now handles GIF files by automatically converting them to JPGs
B) Several of the variables are defined up front rather than being buried in the code, including the path to the file being edited
C) For my particular case a user will be able to use this immediately after uploading a photo, so as a security precaution this code checks the file type and makes sure it's a valid gif or jpg and remakes any jpgs just in case they are actually not valid image files.
D)I cut off the SilverOrange copyright notice here just to save space on this page, but it should, of course, always be included with the file.

####
#################################################

require('classes/CropImage.php');

// Here is the incoming filename, replace logo.gif with whatever your file name is:
$filename="logo.gif";

// Here is the path from index.php to the files being manipulated
$path="files/";

// Here is the name of the large output file you'll create from that input file,
// replace targetfile.jpg with whatever your target file name is.
// This should always be a .jpg no matter what your input was.
$nameout="targetfile.jpg";

// Here is the target thumbnail file's name:
$thumb="thumb.jpg";

// Here we check the mime type of the file to get a variable which will indicate
// if the file is a valid gif, jpg or something else:
$image_size = getimagesize($path . $filename);
if (is_array($image_size)) {
$file_type = $image_size[2];
};

// First we see if it's a gif:
if($file_type==1) {

// This file is a gif, so we open up the output file,
// or create it if it doesn't already exist and convert the gif to jpg:

$pointer=fopen($path . $nameout, "w");
imagejpeg(imagecreatefromgif($path . "/" . $filename), $path . "/" . $nameout);
fclose($pointer);

// If it wasn't a gif to begin with, then we check to see if it's a jpg:
} elseif ($file_type==2) {

// This file is a jpg, but we're going to recreate it anyway.
// This way a faked or corrupt jpg will fail now rather than during retrieval.
// You only need to do this with user uploaded files.
$img = imagecreatefromjpeg($path . $filename);
imagejpeg($img, $path . $nameout);
imagedestroy($img);

// If it wasn't a gif or jpg to begin with, then we give a failure message:
} else {
echo "This file does not appear to be a valid GIF or JPG file.<br>";
};

if (isset($_POST['process'])) $process=$_POST['process']; else $process=0;

$cropper=new CropImage($path . $nameout,1,400,400,4,5);
//for Java version use:
// $cropper=new CropImageJava('$nameout',1,400,400,4,5);

$cropper->hiddenvars=array('process'=>1);
$cropper->action='index.php';
$cropper->appletpath='classes';

if ($process==0) {
$cropper->display();
} elseif ($process==1) {
$filename=$path . $thumb;
$cropper->process(200,200,$thumb,false);
echo '<img src="',$thumb,'"?t=',time(),'>';
}
?>
</body>

John -

Has anyone managed to tweak the code so that the cropping box is free/uncontrained and not locked to proportions?

lance -

Awesome tool. thanks.
does anyone know how to make it so you can crop a .jpg that the user supplies?
also, how do you make the cropped .jpg save to a custom location?
im very new at all this so please explain as if explaining to a 4 year old.
thanks

Saqib Jahangir -

Hi,

This is a fantastic effort, I really appriciate it. I try the the demo version of your Image Cropper. But when I download the Source Code and run the index.php in my localhost, it generate the following error:

Fatal error: Call to undefined function imageCreateFromJPEG() in c:\Inetpub\wwwroot\ImageCropper\classes\CropImage.php on line 232

Please guide me, what should I do to remove this error.

Thanks very much,

Bye.

- Saqib

Plan -

Thank you for the tool. But I need to be able to have control over my selection area!

Bernard -

Thank you for the tool! I like it!

Alexander Wahl -

This tool is great and i love it. Great work!
ps: is there a way to include animated GIF Support?

Shrestha -

Awesome tool....!!! thanks a great deal to you guys!!!

However I need to tweak it a lil to fit my requirement.

I need to make it such that the crop box size cannot be changed....
I need to get a fixed size image from the crop...is there a way to exclude the resize part??

Mark Ricard -

When I downloaded the source above for the java cropper, there is only 1 java file in there, but multiple class files. I read that you included all the source in there, but I don't see it?

Demian Curran -

Great software tool !
I am having trouble getting the cropped image to appear, it just shows me a broken image icon. Does this have to do with permisions on my server ? Is there an image write permission I need to enable ?
help ! :)

Demian

Teoman -

I've got problems with big images (more than 2MB). Is there a size Limit?

bozo -

Hi, didn't realise that the cropper was three years old!!! Still works beautifully! Only issue (and this could just be me) - it seems to break if the original image is smaller than the size of the cropper (the image never appears behind the text)... Is that just me or a known bug?

kat -

This is a wonderful thank you! I do have a question, and I wonder if anyone else knows a solution. I would like to have a images upload, and then save into various folders, depending on a key given to them. ex: If and uploaded image had a unique ID of "one" then it would be saved into the "one" folder... if the ID was "two".. it would be saved into the two folder.. any idea what variables I would change to get this to work?
thanks
Kat

Robert -

I came across a website two weeks ago ( searching for it now ) where they had a online photo purchase Flash Cropper (called in the html source code as Cropper2.)
It was a fully functional flash cropping tool that utilized standard photo sizes and once you slected the photo, and chose the size (ie: 4x6, 5x7, 8x10 etc) the correct proportional crop area was superimposed on top of the image. You then used (+) (-) and arrow keys to enlarge it or decreese the crop area. Then once selected, you would go through the payment process and the newly cropped image would be mailed.

Did SilverOrange develope "Cropper2" Or, are you aware of it?

Thanks.

Mike Gauthier -

Robert,

silverorange did not knowingly develop the software you reference. The software you describe seems to have additional features above and beyond what our photo cropper can do.

The BSD license used on our code does allow a 3rd party company to improve our code and sell it as a product provided they leave our copyright notice intact.

We have developed a newer version of our photo cropper that uses Swat and YUI to crop photos using JavaScript. There is a public demo of the image cropper available.

frank basti -

I have been trying to get the cropper to work with ASP without success.

Im not clear on what Parameters i need to pass to the flash movie?
does it read images from XML or are they included in a querystring after the swf name.

if you can point out how the flash movie reads its variables, the names of the variables, and how to add these parameters, i could get the script to also work with ASP!

thanks

Frank Basti

Srihari Padmanabhan -

Thanks for sharing this tool. Works great. It was something that was looking for quite a few days back.