1

Is there a plugin out there that will take an image that is uploaded and resize it to a smaller size so it doesn't fail in the upload process. Basically I have a need for an avatar and the users are uploading various images that are huge from their digital cameras and they tend to be about 2mb or bigger which causes the script to fail... Is there a jQuery plugin that can help me out? I kind of want if to work like the Facebook uploader where it doesn't fail. Any ideas?

By the way this a ColdFusion script, but my expertise is not in ColdFusion so I was hoping jQuery could help.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Matt Elhotiby
  • 43,028
  • 85
  • 218
  • 321
  • I'm pretty sure Facebook allows uploads of massive files and just converts them using PHP on the server side. Don't quote me, but I'm not 100% sure you can resize images in javascript BEFORE sending them to the server – Alex Mar 14 '11 at 15:14
  • A few things to help get your question answered: 1) What is the failure message? 2) What version of ColdFusion are you using? 3) What code are you using on the server side to do the image resizing? A 2mb upload is actually pretty small, and there's no good reason for someone like that to fail if you've got halfway decent code running the resize. – Dan Short Mar 14 '11 at 17:11

4 Answers4

2

Javascript cannot resize images. For that you'll need Flash or java.

Flash upload image resize client side

Community
  • 1
  • 1
JaredMcAteer
  • 21,688
  • 5
  • 49
  • 65
0

As mentioned you can't resize images client-side. I've successfully used IglooLabs jquery Plugin (http://www.igloolab.com/jquery-html5-uploader/). I edited their plugin to do client-side file size (<2MB) and type (jpg, png etc) checks before allowing upload. I can provide edited plugin if you want...

On Upload to the server you can then do an image resize using two lines of code e.g.

<cfimage action="resize" height="" width="750" source="/img/image_to_resize.png" destination="img/resized.png" overwrite="yes" name="resized_image"> 

(Be warned thought that ColdFusion has a bug resizing some jpeg images. Best to convert to .png first)

IanOSullivan
  • 549
  • 1
  • 4
  • 12
0

Or you could do it in PHP and use GD to resize images. Don't need active x or flash or anything else but notepad and a php enabled server.

Lthorne
  • 9
  • 1
  • 3
    Sure. But if the requirement is to reduce amount of traffic uploaded from client machines or to reduce load of your server, this approach doesn't work. –  Jul 20 '11 at 05:49
  • 2
    And the other problem with this technique is that server-side uploads usually have a fixed limit on the size (or amount of memory available). The user doesn't see an error until *after* they've finished their massive upload. Quite frustrating I imagine! – Simon East Sep 19 '11 at 04:34
0

There are some JS scripts that do this for you, but they usually use Flash in the background to do the resizing.

Checkout SwfUpload or PlUpload.

Simon East
  • 55,742
  • 17
  • 139
  • 133