{"action":"created","comment":{"url":"https://api.github.com/repos/Keats/gutenberg/pulls/comments/190651650","pull_request_review_id":123072270,"id":190651650,"diff_hunk":"@@ -0,0 +1,326 @@\n+#[macro_use]\n+extern crate lazy_static;\n+extern crate regex;\n+extern crate image;\n+extern crate rayon;\n+extern crate twox_hash;\n+\n+extern crate utils;\n+extern crate errors;\n+\n+use std::path::{Path, PathBuf};\n+use std::hash::{Hash, Hasher};\n+use std::collections::HashMap;\n+use std::collections::hash_map::Entry as HEntry;\n+use std::fs::{self, File};\n+\n+use regex::Regex;\n+use image::{GenericImage, FilterType};\n+use image::jpeg::JPEGEncoder;\n+use rayon::prelude::*;\n+use twox_hash::XxHash;\n+\n+use utils::fs as ufs;\n+use errors::{Result, ResultExt};\n+\n+\n+static RESIZED_SUBDIR: &'static str = \"_resized_images\";\n+lazy_static!{\n+    pub static ref RESIZED_FILENAME: Regex = Regex::new(r#\"([0-9a-f]{16})([0-9a-f]{2})[.]jpg\"#).unwrap();\n+}\n+\n+/// Describes the precise kind of a resize operation\n+#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n+pub enum ResizeOp {\n+    /// A simple scale operation that doesn't take aspect ratio into account\n+    Scale(u32, u32),\n+    /// Scales the image to a specified width with height computed such that aspect ratio is preserved\n+    FitWidth(u32),\n+    /// Scales the image to a specified height with width computed such that aspect ratio is preserved\n+    FitHeight(u32),\n+    /// Scales the image such that it fits within the specified width and height preserving aspect ratio.\n+    /// Either dimension may end up being smaller, but never larger than specified.\n+    Fit(u32, u32),\n+    /// Scales the image such that it fills the specified width and height. Output will always have the exact dimensions specified.\n+    /// The part of the image that doesn't fit in the thumbnail due to differing aspect ratio will be cropped away, if any.\n+    Fill(u32, u32),\n+}\n+\n+impl ResizeOp {\n+    pub fn from_args(op: &str, width: Option<u32>, height: Option<u32>) -> Result<ResizeOp> {\n+        use ResizeOp::*;\n+\n+        // Validate args:\n+        match op {\n+            \"fitwidth\" => if width.is_none() { return Err(format!(\"op=fitwidth requires a `width` argument\").into()) },","path":"components/imageproc/src/lib.rs","position":55,"original_position":55,"commit_id":"18541553301c2d54cd48963cf3120916286d1a42","original_commit_id":"18541553301c2d54cd48963cf3120916286d1a42","user":{"login":"Keats","id":680355,"avatar_url":"https://avatars2.githubusercontent.com/u/680355?v=4","gravatar_id":"","url":"https://api.github.com/users/Keats","html_url":"https://github.com/Keats","followers_url":"https://api.github.com/users/Keats/followers","following_url":"https://api.github.com/users/Keats/following{/other_user}","gists_url":"https://api.github.com/users/Keats/gists{/gist_id}","starred_url":"https://api.github.com/users/Keats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Keats/subscriptions","organizations_url":"https://api.github.com/users/Keats/orgs","repos_url":"https://api.github.com/users/Keats/repos","events_url":"https://api.github.com/users/Keats/events{/privacy}","received_events_url":"https://api.github.com/users/Keats/received_events","type":"User","site_admin":false},"body":"can we have `fit_width` and `fit_height` to match the usual type of arguments?","created_at":"2018-05-24T16:29:52Z","updated_at":"2018-05-24T16:51:02Z","html_url":"https://github.com/Keats/gutenberg/pull/300#discussion_r190651650","pull_request_url":"https://api.github.com/repos/Keats/gutenberg/pulls/300","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Keats/gutenberg/pulls/comments/190651650"},"html":{"href":"https://github.com/Keats/gutenberg/pull/300#discussion_r190651650"},"pull_request":{"href":"https://api.github.com/repos/Keats/gutenberg/pulls/300"}}},"pull_request":{"url":"https://api.github.com/repos/Keats/gutenberg/pulls/300","id":184836855,"html_url":"https://github.com/Keats/gutenberg/pull/300","diff_url":"https://github.com/Keats/gutenberg/pull/300.diff","patch_url":"https://github.com/Keats/gutenberg/pull/300.patch","issue_url":"https://api.github.com/repos/Keats/gutenberg/issues/300","number":300,"state":"open","locked":false,"title":" Add image resizing support #225","user":{"login":"vojtechkral","id":424891,"avatar_url":"https://avatars2.githubusercontent.com/u/424891?v=4","gravatar_id":"","url":"https://api.github.com/users/vojtechkral","html_url":"https://github.com/vojtechkral","followers_url":"https://api.github.com/users/vojtechkral/followers","following_url":"https://api.github.com/users/vojtechkral/following{/other_user}","gists_url":"https://api.github.com/users/vojtechkral/gists{/gist_id}","starred_url":"https://api.github.com/users/vojtechkral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vojtechkral/subscriptions","organizations_url":"https://api.github.com/users/vojtechkral/orgs","repos_url":"https://api.github.com/users/vojtechkral/repos","events_url":"https://api.github.com/users/vojtechkral/events{/privacy}","received_events_url":"https://api.github.com/users/vojtechkral/received_events","type":"User","site_admin":false},"body":"My image resizing branch. Ended up quite a large change.\r\nHopefully everything is ok, if not, let me know.\r\n\r\nI finally put it together with some documentation.\r\n\r\nI haven't written any tests, I'm not really sure how to go about it, since this is all quite data-dependent...\r\n","created_at":"2018-04-29T14:19:28Z","updated_at":"2018-05-24T16:51:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b1cd71560df4867774445ce8e9466a0c0e980d5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Keats/gutenberg/pulls/300/commits","review_comments_url":"https://api.github.com/repos/Keats/gutenberg/pulls/300/comments","review_comment_url":"https://api.github.com/repos/Keats/gutenberg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Keats/gutenberg/issues/300/comments","statuses_url":"https://api.github.com/repos/Keats/gutenberg/statuses/18541553301c2d54cd48963cf3120916286d1a42","head":{"label":"vojtechkral:pictures","ref":"pictures","sha":"18541553301c2d54cd48963cf3120916286d1a42","user":{"login":"vojtechkral","id":424891,"avatar_url":"https://avatars2.githubusercontent.com/u/424891?v=4","gravatar_id":"","url":"https://api.github.com/users/vojtechkral","html_url":"https://github.com/vojtechkral","followers_url":"https://api.github.com/users/vojtechkral/followers","following_url":"https://api.github.com/users/vojtechkral/following{/other_user}","gists_url":"https://api.github.com/users/vojtechkral/gists{/gist_id}","starred_url":"https://api.github.com/users/vojtechkral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vojtechkral/subscriptions","organizations_url":"https://api.github.com/users/vojtechkral/orgs","repos_url":"https://api.github.com/users/vojtechkral/repos","events_url":"https://api.github.com/users/vojtechkral/events{/privacy}","received_events_url":"https://api.github.com/users/vojtechkral/received_events","type":"User","site_admin":false},"repo":{"id":120028577,"name":"gutenberg","full_name":"vojtechkral/gutenberg","owner":{"login":"vojtechkral","id":424891,"avatar_url":"https://avatars2.githubusercontent.com/u/424891?v=4","gravatar_id":"","url":"https://api.github.com/users/vojtechkral","html_url":"https://github.com/vojtechkral","followers_url":"https://api.github.com/users/vojtechkral/followers","following_url":"https://api.github.com/users/vojtechkral/following{/other_user}","gists_url":"https://api.github.com/users/vojtechkral/gists{/gist_id}","starred_url":"https://api.github.com/users/vojtechkral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vojtechkral/subscriptions","organizations_url":"https://api.github.com/users/vojtechkral/orgs","repos_url":"https://api.github.com/users/vojtechkral/repos","events_url":"https://api.github.com/users/vojtechkral/events{/privacy}","received_events_url":"https://api.github.com/users/vojtechkral/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vojtechkral/gutenberg","description":"An opinionated static site generator with everything built-in.","fork":true,"url":"https://api.github.com/repos/vojtechkral/gutenberg","forks_url":"https://api.github.com/repos/vojtechkral/gutenberg/forks","keys_url":"https://api.github.com/repos/vojtechkral/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vojtechkral/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vojtechkral/gutenberg/teams","hooks_url":"https://api.github.com/repos/vojtechkral/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/vojtechkral/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/vojtechkral/gutenberg/events","assignees_url":"https://api.github.com/repos/vojtechkral/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/vojtechkral/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/vojtechkral/gutenberg/tags","blobs_url":"https://api.github.com/repos/vojtechkral/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vojtechkral/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vojtechkral/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/vojtechkral/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vojtechkral/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/vojtechkral/gutenberg/languages","stargazers_url":"https://api.github.com/repos/vojtechkral/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/vojtechkral/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/vojtechkral/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/vojtechkral/gutenberg/subscription","commits_url":"https://api.github.com/repos/vojtechkral/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/vojtechkral/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/vojtechkral/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/vojtechkral/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/vojtechkral/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/vojtechkral/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vojtechkral/gutenberg/merges","archive_url":"https://api.github.com/repos/vojtechkral/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vojtechkral/gutenberg/downloads","issues_url":"https://api.github.com/repos/vojtechkral/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/vojtechkral/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/vojtechkral/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/vojtechkral/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vojtechkral/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/vojtechkral/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/vojtechkral/gutenberg/deployments","created_at":"2018-02-02T20:36:07Z","updated_at":"2018-04-28T20:38:53Z","pushed_at":"2018-05-24T10:50:04Z","git_url":"git://github.com/vojtechkral/gutenberg.git","ssh_url":"git@github.com:vojtechkral/gutenberg.git","clone_url":"https://github.com/vojtechkral/gutenberg.git","svn_url":"https://github.com/vojtechkral/gutenberg","homepage":"https://www.getgutenberg.io","size":18517,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Keats:next","ref":"next","sha":"3c584c8621bbb017c60e704dff2e63cb43f905cc","user":{"login":"Keats","id":680355,"avatar_url":"https://avatars2.githubusercontent.com/u/680355?v=4","gravatar_id":"","url":"https://api.github.com/users/Keats","html_url":"https://github.com/Keats","followers_url":"https://api.github.com/users/Keats/followers","following_url":"https://api.github.com/users/Keats/following{/other_user}","gists_url":"https://api.github.com/users/Keats/gists{/gist_id}","starred_url":"https://api.github.com/users/Keats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Keats/subscriptions","organizations_url":"https://api.github.com/users/Keats/orgs","repos_url":"https://api.github.com/users/Keats/repos","events_url":"https://api.github.com/users/Keats/events{/privacy}","received_events_url":"https://api.github.com/users/Keats/received_events","type":"User","site_admin":false},"repo":{"id":75688610,"name":"gutenberg","full_name":"Keats/gutenberg","owner":{"login":"Keats","id":680355,"avatar_url":"https://avatars2.githubusercontent.com/u/680355?v=4","gravatar_id":"","url":"https://api.github.com/users/Keats","html_url":"https://github.com/Keats","followers_url":"https://api.github.com/users/Keats/followers","following_url":"https://api.github.com/users/Keats/following{/other_user}","gists_url":"https://api.github.com/users/Keats/gists{/gist_id}","starred_url":"https://api.github.com/users/Keats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Keats/subscriptions","organizations_url":"https://api.github.com/users/Keats/orgs","repos_url":"https://api.github.com/users/Keats/repos","events_url":"https://api.github.com/users/Keats/events{/privacy}","received_events_url":"https://api.github.com/users/Keats/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Keats/gutenberg","description":"A fast static site generator in a single binary with everything built-in.","fork":false,"url":"https://api.github.com/repos/Keats/gutenberg","forks_url":"https://api.github.com/repos/Keats/gutenberg/forks","keys_url":"https://api.github.com/repos/Keats/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Keats/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Keats/gutenberg/teams","hooks_url":"https://api.github.com/repos/Keats/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/Keats/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/Keats/gutenberg/events","assignees_url":"https://api.github.com/repos/Keats/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/Keats/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/Keats/gutenberg/tags","blobs_url":"https://api.github.com/repos/Keats/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Keats/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Keats/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/Keats/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Keats/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/Keats/gutenberg/languages","stargazers_url":"https://api.github.com/repos/Keats/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/Keats/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/Keats/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/Keats/gutenberg/subscription","commits_url":"https://api.github.com/repos/Keats/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/Keats/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/Keats/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/Keats/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/Keats/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/Keats/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Keats/gutenberg/merges","archive_url":"https://api.github.com/repos/Keats/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Keats/gutenberg/downloads","issues_url":"https://api.github.com/repos/Keats/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/Keats/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/Keats/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/Keats/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Keats/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/Keats/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/Keats/gutenberg/deployments","created_at":"2016-12-06T02:57:25Z","updated_at":"2018-05-24T12:18:22Z","pushed_at":"2018-05-24T10:50:05Z","git_url":"git://github.com/Keats/gutenberg.git","ssh_url":"git@github.com:Keats/gutenberg.git","clone_url":"https://github.com/Keats/gutenberg.git","svn_url":"https://github.com/Keats/gutenberg","homepage":"https://www.getgutenberg.io","size":17719,"stargazers_count":891,"watchers_count":891,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":70,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":70,"open_issues":45,"watchers":891,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Keats/gutenberg/pulls/300"},"html":{"href":"https://github.com/Keats/gutenberg/pull/300"},"issue":{"href":"https://api.github.com/repos/Keats/gutenberg/issues/300"},"comments":{"href":"https://api.github.com/repos/Keats/gutenberg/issues/300/comments"},"review_comments":{"href":"https://api.github.com/repos/Keats/gutenberg/pulls/300/comments"},"review_comment":{"href":"https://api.github.com/repos/Keats/gutenberg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Keats/gutenberg/pulls/300/commits"},"statuses":{"href":"https://api.github.com/repos/Keats/gutenberg/statuses/18541553301c2d54cd48963cf3120916286d1a42"}},"author_association":"NONE"}}
{"actor":{"display_login":"Keats"}}