Hey guyz!

I think that I found my answer!

1) Register an dinamic helper:

md5 = require('crypto').createHash 'md5'
app.locals.use (req, res) ->
    app.locals.crop = (image, width, height) ->
        res.crops = new Object if !res.crops
        key =  md5.update(image + width + height).digest 'hex'
        res.crops[key] =
            image : image
            width : width
            height: heitght
        return "/my-serize-proxy/#{key}"

2) Now we can call crop inside the view:

<img src="{{crop(image, 200, 300)}}" />

3) When the system finished parsing the view, we use a callback to catch
all images that we need to store in the database, so the resizing proxy
will receive that hash key and query the image and dimensions inside the db.

app.get '/gallery', (req, res) ->
    res.render 'gallery.html', (err, html) ->
        console.log err if err
        if res.crops
            for crop in res.crops
                #here we will save all crops in the database

        #When we are winished we the crops, we can answer the HTML to the
client
        res.send html

4) Now is just implement the resiging proxy and query the db for the key in
/my-sesizing-proxy/:key and you will know what image and dimensions you'll
need to use!

Ta-da! Resizing without dimensions params in the URL!

--
Att,
Alan Hoffmeister
--
Att,
Alan Hoffmeister


2012/5/23 Alan Hoffmeister <alanhoffmeis...@gmail.com>

> @Marc, great idea, but you still need to limit the image size on the
> upload.. The user can submit an 9999x9999 image and here we go...
>
> --
> Att,
> Alan Hoffmeister
>
>
> 2012/5/23 Marc Deschamps <md.fle...@gmail.com>:
> > I do not allow to resize bigger than original image...
> >
> > Smaller is ok, same size is ok, if bigger, then i return original
> image...
> > Make sense for me
> >
> > --
> > Job Board: http://jobs.nodejs.org/
> > Posting guidelines:
> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> > You received this message because you are subscribed to the Google
> > Groups "nodejs" group.
> > To post to this group, send email to nodejs@googlegroups.com
> > To unsubscribe from this group, send email to
> > nodejs+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to