Circular images often have this problem when compressed, mainly because there is no "half pixel". Note the images below.
Images on high pixel density panels, such as Apple’s Retina panel
Browser does not render images as well as Photoshop for example. So sometimes in Photoshop gets good, but the Browser algorithm may not have the same result compressing images.
Most likely if your image was a square with rows left you wouldn’t have this problem so sharply.
The ideal would be to treat the image in some software made for it. Or turn into .SVG. Treating this kind of thing in the browser for me is gambiarra. You can still use the class image-rendering: crisp-edges;
in the image.
img {
image-rendering: crisp-edges;
}
Here is documentation about the class: https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
Although see how even with her the image-rendering: pixelated;
rendering in Browser is different.
Chrome:
Safari:
Firefox Quantum:
You can also treat the image with Javascript inside a canvas
, as in this example:
To test where False is put True in the script
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var textarea = document.getElementById('code');
var reset = document.getElementById('reset');
var edit = document.getElementById('edit');
var code = textarea.value;
function drawCanvas() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
eval(textarea.value);
}
reset.addEventListener('click', function() {
textarea.value = code;
drawCanvas();
});
edit.addEventListener('click', function() {
textarea.focus();
})
textarea.addEventListener('input', drawCanvas);
window.addEventListener('load', drawCanvas);
<canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas>
<div class="playable-buttons">
<input id="edit" type="button" value="Edit" />
<input id="reset" type="button" value="Reset" />
</div>
<textarea id="code" class="playable-code" style="height:140px;">
var img = new Image();
img.src = 'https://mdn.mozillademos.org/files/222/Canvas_createpattern.png';
img.onload = function() {
ctx.mozImageSmoothingEnabled = false;
ctx.webkitImageSmoothingEnabled = false;
ctx.msImageSmoothingEnabled = false;
ctx.imageSmoothingEnabled = false;
ctx.drawImage(img, 0, 0, 400, 200);
};</textarea>
Source: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled
Are you giving these problems to all browsers? Have you considered turning . png into . svg?
– hugocsl
This wasn’t supposed to happen. Maybe it’s the format or the image encoding. If you can make the original image available for download to be analyzed would be good.
– Sam