Would it be possible to identify the subset of pixels that represent the area under the text from the image data? Then we could reapply the algorithm to a smaller size making it significantly less complex. My main concern with the original implementation would be the cost of scanning a high-resolution image. The profiling algorithm could probably be best applied after the upload on the upload service itself and store the profiling data with the image then we can just fetch the image and it's profiling data and don't have to scan it on client's device.
Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
It's not too bad as long as you know (or can get) three things:
the size the image will be when rendered
the pixel position of the text relative to the top-left corner of the image
the approximate height and width of the text when rendered
That last bit is the hard part, especially if there's any line breaks involved. But after you have those, it's basically this:
conststart={x:imgleft+textrelleft,y:imgtop+textreltop}constend={x:imgleft+textrelleft+textwidth,y:imgtop+textreltop+textheight}for(constx=start.x;x<end.x;x++){for(consty=start.y;y<end.y;y++){constp=(canvas.width*y+x)*4const[r,g,b]=[].slice.call(data,p,p+3)// fancy logic of choice}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Would it be possible to identify the subset of pixels that represent the area under the text from the image data? Then we could reapply the algorithm to a smaller size making it significantly less complex. My main concern with the original implementation would be the cost of scanning a high-resolution image. The profiling algorithm could probably be best applied after the upload on the upload service itself and store the profiling data with the image then we can just fetch the image and it's profiling data and don't have to scan it on client's device.
I think it can be. But it might take a lot of werid calculations to do something like that. But I’m up for the challenge. 😎
It's not too bad as long as you know (or can get) three things:
That last bit is the hard part, especially if there's any line breaks involved. But after you have those, it's basically this: