[whatwg] getImageData/putImageData comments

Boris Zbarsky bzbarsky at MIT.EDU
Fri Jul 10 16:34:06 PDT 2009

Ian Hickson wrote:
>> For another example, consider an algorithm that wants to reduce the size of
>> the image by 1px horizontally (e.g. content-aware image resizing as demoed
>> using canvas at
>> <http://labs.pimsworld.org/wp-content/uploads/2009/04/demo-content-aware-image-resizing-2/>).
>> If we're shrinking by one device pixel, then suddenly we can't even create a
>> canvas of the right size for the new image, because canvas size is specified
>> in integer CSS pixels.  Note that the algorithm used here, basically
>> off-the-shelf, would in fact want to work on device pixels the way the spec is
>> written right now; in general it would want to work on whatever pixels
>> imagedata is in.
> If you want to shrink an image, redraw it using drawImage() with different 
> dimensions.

You apparently didn't look at the linked-to page.  It's basically 
applying a graphical filter to an image that results in a smaller image. 
    It's explicitly NOT trying to resize the image using whatever 
algorithm the browser happens to implement; it's implementing its own 
image-resizing algorithm (one that arguably produces much better results 
at the cost of a lot more computation).

> I don't know what we can do about it either, though.

I'll think about this some more... I'm not too hopeful, though.  :( 
Especially for that image-resizing case, where we basically need to be 
able to create a canvas with fractional CSS pixel dimensions or something.


More information about the whatwg mailing list