{"action":"created","issue":{"url":"https://api.github.com/repos/oliver-moran/jimp/issues/54","labels_url":"https://api.github.com/repos/oliver-moran/jimp/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/oliver-moran/jimp/issues/54/comments","events_url":"https://api.github.com/repos/oliver-moran/jimp/issues/54/events","html_url":"https://github.com/oliver-moran/jimp/issues/54","id":111772119,"number":54,"title":"Image quality getting bad","user":{"login":"canvas-manik","id":11735090,"avatar_url":"https://avatars.githubusercontent.com/u/11735090?v=3","gravatar_id":"","url":"https://api.github.com/users/canvas-manik","html_url":"https://github.com/canvas-manik","followers_url":"https://api.github.com/users/canvas-manik/followers","following_url":"https://api.github.com/users/canvas-manik/following{/other_user}","gists_url":"https://api.github.com/users/canvas-manik/gists{/gist_id}","starred_url":"https://api.github.com/users/canvas-manik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/canvas-manik/subscriptions","organizations_url":"https://api.github.com/users/canvas-manik/orgs","repos_url":"https://api.github.com/users/canvas-manik/repos","events_url":"https://api.github.com/users/canvas-manik/events{/privacy}","received_events_url":"https://api.github.com/users/canvas-manik/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-10-16T06:47:56Z","updated_at":"2015-11-09T23:08:00Z","closed_at":"2015-10-28T09:15:16Z","body":"Hi,\r\n\r\nI am new to image optimization. I just want to optimize my images tomake them small in size and dimension, but maintaining quality. I used the following code:\r\n\r\n```js\r\nnew Jimp(\"img.jpg\", function (err, image) {\r\n        if(!err){\r\n            var origImageDim = {width:this.bitmap.width,height:this.bitmap.height};\r\n            var dimensions = calculateImageDimensions(origImageDim.width,origImageDim.height,600,400);//Get proportionate dimensions\r\n            var imageClone = image.clone();\r\n            image.cover(dimensions.width, dimensions.height).write(\"destFolder/img.jpg\", function(err, image){\r\n                    if(!err){\r\n                        console.log(\"Image optimised successfully\");\r\n                    }\r\n                    else{\r\n                        console.log(err);\r\n                    }\r\n                }\r\n            )\r\n\t\t}\r\n\t}\r\n\t\r\n\tfunction calculateImageDimensions(width,height,maxWidth,maxHeight){\r\n    // calculate the width and height, constraining the proportions\r\n    if (width > height) {\r\n        if (width > maxWidth) {\r\n            height = Math.round(height *= maxWidth / width);\r\n            width = maxWidth;\r\n        }\r\n    }\r\n    else {\r\n        if (height > maxHeight) {\r\n            width = Math.round(width *= maxHeight / height);\r\n            height = maxHeight;\r\n        }\r\n    }\r\n    return {width:width,height:height};\r\n}\r\n```\r\nThe problem i am facing is that the quality of the resultant image is getting bad and the size (KB's) is  getting bigger. Can you please help? Am I doing anything wrong?\r\n\r\n![orig-image](https://cloud.githubusercontent.com/assets/11735090/10535342/cb2c2cb8-73ff-11e5-8188-a5d6cb3528a2.jpg)\r\n![resultant-image](https://cloud.githubusercontent.com/assets/11735090/10535343/cb309a6e-73ff-11e5-9add-4d2bb0502018.jpg)\r\n"},"comment":{"url":"https://api.github.com/repos/oliver-moran/jimp/issues/comments/155227765","html_url":"https://github.com/oliver-moran/jimp/issues/54#issuecomment-155227765","issue_url":"https://api.github.com/repos/oliver-moran/jimp/issues/54","id":155227765,"user":{"login":"lovell","id":210965,"avatar_url":"https://avatars.githubusercontent.com/u/210965?v=3","gravatar_id":"","url":"https://api.github.com/users/lovell","html_url":"https://github.com/lovell","followers_url":"https://api.github.com/users/lovell/followers","following_url":"https://api.github.com/users/lovell/following{/other_user}","gists_url":"https://api.github.com/users/lovell/gists{/gist_id}","starred_url":"https://api.github.com/users/lovell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovell/subscriptions","organizations_url":"https://api.github.com/users/lovell/orgs","repos_url":"https://api.github.com/users/lovell/repos","events_url":"https://api.github.com/users/lovell/events{/privacy}","received_events_url":"https://api.github.com/users/lovell/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T23:08:00Z","updated_at":"2015-11-09T23:08:00Z","body":"> \"Jimp uses a bi-cubic two-pass scaling algorithm\"\r\n\r\n@oliver-moran Hello, has `jimp` switched from bilinear to bicubic interpolation recently? I'll be updating `sharp`'s [performance test results](http://sharp.dimens.io/en/stable/performance/) soon and want to ensure I'm correctly categorising it."}}