fix for blurry images on browsers used by a mac retina - image

I am making a game sorta like cookie clicker, and I want the images to look 8 bit. I use a macbook pro retina, which has four pixels for every one pixel on a normal screen. On Chrome and Safari, instead of each pixel being represented by 2x2 pixels, I get a bunch of blurry blobs... I don't have this problem on FireFox. There's this one website called pixeljoint.com that is made for pixel art, and I don't have the blurry problem there. Whenever I open one of the images from PixelJoint in a new tab, the image goes back to blurry. I heard that the problem is that the images are scaled before they are displayed on chrome and safari, but I'm not too sure.
Here are two screenshots to show what I'm talking about:
I would also like to point out that the images are normal .gif files.
I am aware that you can convert a gif file to an svg with this link
and an svg file looks fine on retina.
All I want to know is how PixelJoint makes the pixels look so smooth.

I figured it out, you need to use CSS!
<style>
img {image-rendering: optimizeSpeed;image-rendering: -moz-crisp-edges;image-rendering: -webkit-optimize-contrast;image-rendering: optimize-contrast;image-rendering: pixelated; -ms-interpolation-mode: nearest-neighbor; }
</style>
I found this in the source code, so I guess this is how PixelJoint does it.

Related

Responsive images srcset not behaving as expected

I am trying to implement a full screen responsive image solution with the following loose requirements
0-600px > displays small image
601-900px > displays medium image
901-2000px > displays large image
After a bit of digging, I decided to work with the dimensions for:
iphone 6 > 414x736
ipad > 768x1024
I created separate images for each screen size (art direction purposes) and used the following srcset code
<img src="/assets/images/414X736/artGallery.jpg"
srcset="/assets/images/414X736/artGallery.jpg 414w,
/assets/images/768x1024/artGallery.jpg 768w,
/assets/images/1920x1080/artGallery.jpg 1920w">
The images have the following CSS (so it behaves like background:cover)
img {
display:block;
height:100vh;
width:100vw;
object-fit:cover;
}
I sized my desktop monitor small, and resized until full screen, the images where substituted at the right place
However, on my phones and tablets, it consistently showed the 1920 image
Ideally, I would like to substitue the images when scaling the browser window from small to large and large to small
My understanding of srcset is that once it's loaded the largest image, it doesn't load smaller ones
Help and suggestions appreciated
If you want to make some sort of Art Direction, you need to use <picture> instead of srcset-w.
By the way, your code misses a sizes attribute, which is mandatory if you use the srcset attribute with w descriptors.

Firefox Addon manager blurry icons

I created an extension for Firefox and made a simple icon for it.
But when I tested it in the Addon manager the icon appeared blurry despite my source image was fine.
I started to experiment with different sizes and shapes of the icon.
Figured out that the icon container is 48x48 pixels and the default addon icon is 32x32.
But for any experiments the result was the same.
So I created a simple rectangle icon drawing it by pixels so it shouldn't blur anyway:
But the result blurred again:
There is some sub-pixels around the rectangle though the border should be crisp...
In pixels view:
Also I found the default extension icon (a puzzle piece) and in pixels it looks perfect but in the manager the borders are blurred a little though it's not obvious at first glance.
Are you sure this is not happening when you save the image? I don't know what app you are using, but many photo apps try to compress jpm images when you save them by default. Check this first.
Usually this does not happen with png images, so you could try using a png image instead as well.
It was silly enough... The broblem was the page scale not 100% on the Addons page. Pressed Ctrl+0 and all restored.
It happens sometimes on other web pages when I zoom in/out the view and images lose their sharpness.

IE 10 & PNG Files As Background Image

We have a sprite of many icons which is 10564px x 80px. The icons are arranged horizontally.
In every other browser except IE10 the icons/images show up when being used as background images for tags with specific CSS to apply the relevant position.
When viewed in IE10 they do not show up at all and actually when you try to view the png file directly from the URL in IE10 it doesn't show either.
Any ideas?
After extensive testing, it turns out it's a limitation on the width of the PNG canvas and IE10.
PNG images would work and can be viewed right up until 8000px wide but no more than that, after that they just don't render.
After more testing it's related to whether or not they are transparent. PNGs with transparency just don't show at all whereas images without transparency show as a black block (canvas).
Whether or not MS will fix this remains to be seen... we live in hope!
The fix for us is to reduce the width of our sprite to 8000px and have two or more rows of icons/images well spaced out.
The fixes is only to separate the each individual image as single with minimum size, which will be less than 8000px wide;

Chrome resizes svg images

I have an img menu with svg images that changes the svg image with a identical image with a different color when you push in menu. When I test it with Chrome it works fine until you visit one link the second time, that chrome resize it to a smaller image.
I've made a lot of tests... I've tested :visited css, user agent css, and many another properties and it seems to be all ok. When you changes some css property in developer tools it changes automagically to correct size.
My last test was to change the width from 135px to 134px (don't ask why) and it works in 1680x1050 screen but not in 1920x1200 screen (???????). Is it an aspect ratio problem?
I'm getting crazy!!
I'm using angularjs to make the black image to red image change, but I think this is not the problem (it does a src replacement)
You can see it in the webpage http://silviaperezcruz.com.
I'll apreciate any kind of help.
PD: Sorry for my bad english
I couldn't see an obvious reason why it is doing it,. But if I had to guess, I would cast a suspicious eye on respond.js first. Does it still do it if you remove that?

Safari Rendering image background black on load

I'm currently working on a website and having an issue with Safari. When loading an image there is a black background that is placed as a stand in. I would rather this be transparent or white, but I can't seem to figure it out. Check it out:
http://blazing-ocean-6482.herokuapp.com/
I've made html and body have background-color:white; but this doesn't seem to have changed the issue.
Just save the PNG image with interlaced option
I had the same problem in safari 6.
My image was in grayscale color space. I switched it to rgb and the problem disappeared.
Try to check your images color space settings!
This happens because the PNG has no alpha channel.
Photoshop saves the image with the alpha channel only if the image has transparent pixels.
In order to work properly in Safari, IHDR chunk of PNG image must have "truecolor-apha" in it contents.
You can see the png chunks in tweakpng (http://entropymine.com/jason/tweakpng/) or similar programs.
I've had the same issue as above (only in Safari too). My body tag has a background image, is repeat-x and is used as the background for the whole website. When a user goes to the page in Safari, there is a flash of black on page load. I've searched for ages for a solution to this, but it appears to be an unresolved bug with Safari.
I'ved tried adding "style: background-color: #FFF" to the html and body tags and also tried using the old school "bgcolor: #FFF" - none work.
The only way I could get Safari to behave was to use CSS + jQuery. Give the body a class of "bg-on" in your html and CSS files. In a linked .js file or in the of your html page in tags:
jQuery(function ($) {
$(document).ready(function(){
$('body').removeClass('bg-on');
});//end document ready
/* NOTE (window).load fires when images have been fully loaded */
$(window).load(function() {
$('body').addClass('bg-on');
});//end window load function
});//end jQuery function no conflict mode
What the above does is when the DOM is loaded by the browser, it removes the class from the body, therefore Safari won't show a black background as no background-image is there. Then when the window.load event fires, when all assets have been loaded, the body is given the background image...
It won't affect JS disabled browsers either, as the class of "bg-on" is hardcoded into the html.
Not a particularly elegant solution, but it works for me.
I had this problem recently in Safari 6.0.2, which also showed up in mobile Safari (at least in iOS 6). Saving my background as interlaced didn't work across the board & the colour space was RGB. Thankfully my background had very few colours & converting it to GIF fixed the problem entirely.
My problem was, that I have uploaded correct file, but with page builder I have edited the image - and was converted to jpg from png.
First make png with alpha and then upload - worked.

Resources