{"action":"closed","issue":{"url":"https://api.github.com/repos/danmichaelo/croptool/issues/39","labels_url":"https://api.github.com/repos/danmichaelo/croptool/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/danmichaelo/croptool/issues/39/comments","events_url":"https://api.github.com/repos/danmichaelo/croptool/issues/39/events","html_url":"https://github.com/danmichaelo/croptool/issues/39","id":39375428,"number":39,"title":"Determine jpeg sampling factor","user":{"login":"danmichaelo","id":434495,"avatar_url":"https://avatars.githubusercontent.com/u/434495?v=3","gravatar_id":"","url":"https://api.github.com/users/danmichaelo","html_url":"https://github.com/danmichaelo","followers_url":"https://api.github.com/users/danmichaelo/followers","following_url":"https://api.github.com/users/danmichaelo/following{/other_user}","gists_url":"https://api.github.com/users/danmichaelo/gists{/gist_id}","starred_url":"https://api.github.com/users/danmichaelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmichaelo/subscriptions","organizations_url":"https://api.github.com/users/danmichaelo/orgs","repos_url":"https://api.github.com/users/danmichaelo/repos","events_url":"https://api.github.com/users/danmichaelo/events{/privacy}","received_events_url":"https://api.github.com/users/danmichaelo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/danmichaelo/croptool/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-08-03T18:09:25Z","updated_at":"2015-09-20T19:53:40Z","closed_at":"2015-09-20T19:53:40Z","body":"If we want to know beforehand where a lossless crop can be made, we need to know what the MCU block size for the given image is.\r\n\r\nThe block size depends on the chroma subsampling ratio:\r\n* 4:4:4 – no subsampling => 8x8\r\n* 4:2:2 => 16x8\r\n* 4:2:0 => 16x16 (most common)\r\n\r\n`identify -format \"%[jpeg:sampling-factor]\" filename.jpg` gives either \r\n`2x2,1x1,1x1` or `1x2,1x1,1x1` or `2x1,1x1,1x1` or `1x1,1x1,1x1` on the current temp files.\r\n\r\n<s>We might be able to get the same from http://php.net/manual/en/imagick.getsamplingfactors.php</s> (just returns an empty array)\r\n\r\nBut this works:\r\n\r\n   $image = new Imagick($path);\r\n        $this->samplingFactors = $image->GetImageProperty('jpeg:sampling-factor');"}}