{"action":"created","issue":{"url":"https://api.github.com/repos/haraldk/TwelveMonkeys/issues/233","repository_url":"https://api.github.com/repos/haraldk/TwelveMonkeys","labels_url":"https://api.github.com/repos/haraldk/TwelveMonkeys/issues/233/labels{/name}","comments_url":"https://api.github.com/repos/haraldk/TwelveMonkeys/issues/233/comments","events_url":"https://api.github.com/repos/haraldk/TwelveMonkeys/issues/233/events","html_url":"https://github.com/haraldk/TwelveMonkeys/issues/233","id":145152475,"number":233,"title":"Tiff reader/writer corrupts image data.","user":{"login":"barryspearce","id":18211861,"avatar_url":"https://avatars.githubusercontent.com/u/18211861?v=3","gravatar_id":"","url":"https://api.github.com/users/barryspearce","html_url":"https://github.com/barryspearce","followers_url":"https://api.github.com/users/barryspearce/followers","following_url":"https://api.github.com/users/barryspearce/following{/other_user}","gists_url":"https://api.github.com/users/barryspearce/gists{/gist_id}","starred_url":"https://api.github.com/users/barryspearce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barryspearce/subscriptions","organizations_url":"https://api.github.com/users/barryspearce/orgs","repos_url":"https://api.github.com/users/barryspearce/repos","events_url":"https://api.github.com/users/barryspearce/events{/privacy}","received_events_url":"https://api.github.com/users/barryspearce/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/haraldk/TwelveMonkeys/labels/Bug","name":"Bug","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"haraldk","id":110299,"avatar_url":"https://avatars.githubusercontent.com/u/110299?v=3","gravatar_id":"","url":"https://api.github.com/users/haraldk","html_url":"https://github.com/haraldk","followers_url":"https://api.github.com/users/haraldk/followers","following_url":"https://api.github.com/users/haraldk/following{/other_user}","gists_url":"https://api.github.com/users/haraldk/gists{/gist_id}","starred_url":"https://api.github.com/users/haraldk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haraldk/subscriptions","organizations_url":"https://api.github.com/users/haraldk/orgs","repos_url":"https://api.github.com/users/haraldk/repos","events_url":"https://api.github.com/users/haraldk/events{/privacy}","received_events_url":"https://api.github.com/users/haraldk/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/haraldk/TwelveMonkeys/milestones/5","html_url":"https://github.com/haraldk/TwelveMonkeys/milestones/3.3","labels_url":"https://api.github.com/repos/haraldk/TwelveMonkeys/milestones/5/labels","id":923615,"number":5,"title":"3.3","description":"","creator":{"login":"haraldk","id":110299,"avatar_url":"https://avatars.githubusercontent.com/u/110299?v=3","gravatar_id":"","url":"https://api.github.com/users/haraldk","html_url":"https://github.com/haraldk","followers_url":"https://api.github.com/users/haraldk/followers","following_url":"https://api.github.com/users/haraldk/following{/other_user}","gists_url":"https://api.github.com/users/haraldk/gists{/gist_id}","starred_url":"https://api.github.com/users/haraldk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haraldk/subscriptions","organizations_url":"https://api.github.com/users/haraldk/orgs","repos_url":"https://api.github.com/users/haraldk/repos","events_url":"https://api.github.com/users/haraldk/events{/privacy}","received_events_url":"https://api.github.com/users/haraldk/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":6,"state":"open","created_at":"2015-01-06T10:43:47Z","updated_at":"2016-04-04T07:47:57Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-04-01T11:16:12Z","updated_at":"2016-04-04T07:51:41Z","closed_at":null,"body":"The Tiff reader (possibly writer) damages images. I am using standard options to the writer for an uncompressed image.\r\n\r\nThe steps to reproduce are:\r\nLoad a source image (jpg/tiff/png) into BufferedImage\r\nRedraw the loaded image onto a new buffered image forced to INT_RGB and white BG instead of transparency. New image is same width/height.\r\nSHA256 pixels.\r\nSame image to disk.\r\nRepeat using saved image as the new image to load.\r\n\r\nUsing a JPG initial then writing TIFF and doing 2 further iterations with TIFF images the TIFF images degrade rapidly. There is clearly an alignment problem. The SHA256 changes every time.\r\n\r\nUsing the same JPG image but writing PNG and doing 2 further iterations with PNG images the images remain constant and the SHA256 remains stable.\r\n\r\nIll knock up a noddy to isolate for testing but essentially the code (note this is extracted and edited - not running code but is used to provide the salient information) is:\r\n\r\n       BufferedImage loadedImage = ImageIO.read(source.toFile());\r\n        width = loadedImage.getWidth();\r\n        height = loadedImage.getHeight();\r\n\r\n        //\r\n        // Turn whatever we have coming in into a straight RGB image without\r\n        // transparency, converting from original colourspace to RGB. \r\n        //\r\n        image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\r\n        image.createGraphics().drawImage(loadedImage, 0, 0, Color.WHITE, null);\r\n        sha256Image(image);\r\n\r\n        File imgOutFile = new File(filename);\r\n        ImageIO.write(image, \"tiff\", imgOutFile);`\r\n\r\nand sha256 (Using BouncyCastle as provider) is obtain by:\r\n\r\n        ByteBuffer byteBuffer = ByteBuffer.allocate(4 * width * height);\r\n        for (int y = 0; y < height; y++)\r\n        {\r\n            for (int x = 0; x < width; x++)\r\n            {\r\n                byteBuffer.putInt(img.getRGB(x, y));\r\n            }\r\n        }\r\n\r\n        // hash.reset();\r\n        hash = MessageDigest.getInstance(\"SHA-256\", \"BC\");\r\n        hash.update(byteBuffer.array());\r\n        return Hex.toHexString(hash.digest());`\r\n\r\nAs I said Ill get a full class together to show the issue in full but this should be enough to understand the problem.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/haraldk/TwelveMonkeys/issues/comments/205179009","html_url":"https://github.com/haraldk/TwelveMonkeys/issues/233#issuecomment-205179009","issue_url":"https://api.github.com/repos/haraldk/TwelveMonkeys/issues/233","id":205179009,"user":{"login":"haraldk","id":110299,"avatar_url":"https://avatars.githubusercontent.com/u/110299?v=3","gravatar_id":"","url":"https://api.github.com/users/haraldk","html_url":"https://github.com/haraldk","followers_url":"https://api.github.com/users/haraldk/followers","following_url":"https://api.github.com/users/haraldk/following{/other_user}","gists_url":"https://api.github.com/users/haraldk/gists{/gist_id}","starred_url":"https://api.github.com/users/haraldk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haraldk/subscriptions","organizations_url":"https://api.github.com/users/haraldk/orgs","repos_url":"https://api.github.com/users/haraldk/repos","events_url":"https://api.github.com/users/haraldk/events{/privacy}","received_events_url":"https://api.github.com/users/haraldk/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T07:51:41Z","updated_at":"2016-04-04T07:51:41Z","body":"Hi again Barry,\r\n\r\nThanks for providing a test and sample data!\r\n\r\nAfter some research, I believe this is a duplicate of #220 and that the bug is fixed in the master branch.\r\nWith the fix applied, the images seems unchanged between each iteration.\r\n\r\n The fix will be released as part of the next version. Sorry about the inconvenience.\r\n\r\nBest regards,\r\n\r\n-- \r\nHarald K"}}