Has anyone experimented with removing the white (un-used) part of the image using CSS/JS? I have an image (https://i.stack.imgur.com/qXAHZ.jpg) that contains actual content surrounded by lots of whitespace that I want to remove using pure CSS if possible (perhaps position:absolute; clip:rect(0px,60px,200px,0px);
or background-size:cover;
or a combination), but unfortunately the location of the actual content in the image file is not known. The desired results is showing the wallet by itself.
I would much rather avoid a JS solution but if there's something that works and fairly performant, it will be awesome! It's possible to do in PIL
(Trim whitespace using PIL), but it would nice to avoid it if we have a frontend solution that works well 80%+ of the times.
Update: what's the best way to smartly guess (or at least assume) the background position or clip location in a relative way (percentages)? Is it better to use a combination of background-position
, clip
, and background-size
to get the desired effect?