I would use a calculation where you get the width in pixels divided by the square width, and then the height divided by the square height. This will give you the lower resolution you are looking for.
Then you can find a way to change the resolution to the result or capture the color of each pixel in the position (height and width) / 2 squares you are looking for. Then generate them into div tags or a table with the appropriate color and size, resulting in an image yourself.
I have probably a faster idea where you can have multiple versions of the image and change your z-index or their visibility when scrolling. Basically, each image will have different resolutions. If you need to do this with many images, then this solution will not be as effective as a lot of image editing, but you can always do batch editing.
Let me see, if I can come up with more ideas, then I will edit.
source share