Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to Crop image white space automatically using jQuery? Re: How to Crop image white space automatically using jQuery?

#135872
CrocoDillon
Participant

I imagine leading and trailing rows and columns with just white pixels.

You can’t with jQuery, you can with the canvas API.

Draw image to canvas, get image data from canvas, iterate over the pixels removing leading and trailing rows and columns and then put the image data back on the canvas.

This might help you to get started: http://www.html5canvastutorials.com/advanced/html5-canvas-get-image-data-tutorial/ it has all the bits you need.