 # create photo.screen_du : a DataURL encoded thumbnail of photo.img
 makeScreenDataURI = (photo, next) ->
 
-    photo.screen_du = resize photo, 1200, 800
+    photo.screen_du = resize photo, 1200, 800, false
 
     next()
 

# create photo.thumb_du : a DataURL encoded thumbnail of photo.img
makeThumbDataURI = (photo, next) ->

    photo.thumb_du = resize photo, 100, 100
    # let the view update itself
    photo.set 'thumbsrc', photo.thumb_du
    photo.set 'state'   , 'thumbed'

        photo.img.onload = ->
            next()

resize = (photo, MAX_WIDTH, MAX_HEIGHT, fill) ->

    max = width: MAX_WIDTH, height:MAX_HEIGHT
    if (photo.img.width > photo.img.height) is fill
        ratiodim = 'height'
    else
        ratiodim = 'width'

    ratio = max[ratiodim] / photo.img[ratiodim]

    newdims =
        height: ratio*photo.img.height
        width: ratio*photo.img.width


    # use canvas to resize the image
    canvas = document.createElement 'canvas'
    canvas.width = if fill then MAX_WIDTH else newdims.width
    canvas.height = if fill then MAX_HEIGHT else newdims.height
    ctx = canvas.getContext '2d'
    ctx.drawImage photo.img, 0, 0, newdims.width, newdims.height
    return canvas.toDataURL photo.file.type

blobify = (dataUrl, type) ->
