Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to crop and upload image with express?

i upload image on S3 server with knox on express.

I would like user could crop the image for this profile picture (like on facebook)

I heard about Jcrop for the user interface and imagemagick for the server. For you, what is the best way to do that ?

Sorry for my bad english.

like image 225
zobi8225 Avatar asked Jun 19 '12 14:06

zobi8225


People also ask

How do I upload an image using Express?

Open the local page http://127.0.0.1:2000/ to upload the images. Select an image to upload and click on "Upload Image" button. Here, you see that file is uploaded successfully. You can see the uploaded file in the "Uploads" folder.

How do I crop a photo in high resolution?

Select the Picture Tools > Format tab and select Crop. There are different ways to crop your picture: Drag a cropping handle to crop it from the side, top, or bottom. Press Shift to crop the entire photo down to the size you want.


2 Answers

You can try to use nice library GraphicsMagick for node.js https://github.com/aheckmann/gm

and here is a link to test some function and so on http://aheckmann.github.com/gm/

var gm = require('gm')
  , resizeX = 200
  , resizeY = 400

gm('/path/to/image.jpg')
.resize(resizeX, resizeY)
.write(response, function (err) {
  if (err) ...
});
like image 159
lc0 Avatar answered Sep 22 '22 16:09

lc0


I know this answer is a little late, but I have been working on a module (called Picsee) that does just this, check it out here. It uploads photos, crops photos (you need a client-side library), and saves multiple versions based on your configuration. It uses GD, not Image- or GraphicsMagick.

There is also a demo app that demonstrates how to upload, crop, and save multiple versions of the image. And the example is using JCrop. Eventually I hope to add S3 support as well as several other features.

like image 25
User 1058612 Avatar answered Sep 21 '22 16:09

User 1058612