croppercropperjs

Cropper.js: No smoothing with zoom?


I'm using Cropper.js and wondering if anyone knows if it's possible to stop it smoothing out the image when you zoom in. I want it to stay pixelated because I want to use it to crop video game sprite sheets.


Solution

  • I've actually just worked it out. You can add this CSS:

    img { 
        image-rendering: optimizeSpeed;             /*                     */
        image-rendering: -moz-crisp-edges;          /* Firefox             */
        image-rendering: -o-crisp-edges;            /* Opera               */
        image-rendering: -webkit-optimize-contrast; /* Chrome (and Safari) */
        image-rendering: optimize-contrast;         /* CSS3 Proposed       */
        -ms-interpolation-mode: nearest-neighbor;   /* IE8+                */
        image-rendering: pixelated                  /* Confirmed working in Chrome
        }
    

    I found the whole thing minus the last line here but it wasn't working on Chrome so I added the last line found here and now it's working.