Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Crunch
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Crunch
Commits
6ddb528b
Verified
Commit
6ddb528b
authored
2 years ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Update crate info
parent
beec3fa7
No related branches found
No related tags found
No related merge requests found
Pipeline
#339
waiting for manual action with stages
Stage:
Stage:
in 45 seconds
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+1
-1
1 addition, 1 deletion
Cargo.lock
Cargo.toml
+4
-1
4 additions, 1 deletion
Cargo.toml
README.md
+2
-0
2 additions, 0 deletions
README.md
src/cli_args.rs
+16
-15
16 additions, 15 deletions
src/cli_args.rs
with
23 additions
and
17 deletions
Cargo.lock
+
1
−
1
View file @
6ddb528b
...
...
@@ -174,7 +174,7 @@ dependencies = [
[[package]]
name = "crunch-cli"
version = "0.5.
0
"
version = "0.5.
1
"
dependencies = [
"anyhow",
"clap",
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
4
−
1
View file @
6ddb528b
[package]
name
=
"crunch-cli"
version
=
"0.5.
0
"
version
=
"0.5.
1
"
edition
=
"2021"
homepage
=
"https://microhacks.lcr.app/crunch/"
repository
=
"https://lab.lcr.gr/microhacks/crunch"
license
=
"GPL-3.0"
description
=
"Command line asset manipulation, set up a pipeline once and run it against all of your files"
authors
=
[
...
...
This diff is collapsed.
Click to expand it.
README.md
+
2
−
0
View file @
6ddb528b
...
...
@@ -2,6 +2,8 @@
Command line image manipulation, set up a pipeline once and run it against all of your assets
For more info, check out
[
the docs
](
https://microhacks.lcr.app/crunch
)
## Usage
Crunch takes an image and applies a transformation to it. But what if you want to do
**two**
transformations?
...
...
This diff is collapsed.
Click to expand it.
src/cli_args.rs
+
16
−
15
View file @
6ddb528b
...
...
@@ -12,7 +12,7 @@ use crate::load_image;
#[derive(Parser,
Debug,
Clone,
Serialize,
Deserialize)]
#[clap(name
=
"crunch"
)]
#[clap(author
=
"Louis Capitanchik <louis@microhacks.co.uk>"
)]
#[clap(version
=
"0.5.
0
"
)]
#[clap(version
=
"0.5.
1
"
)]
#[clap(about,
long_about
=
None)]
#[serde(tag
=
"command"
,
content
=
"params"
)]
pub
enum
Args
{
...
...
@@ -80,20 +80,20 @@ impl Args {
.save_with_format
(
&
flip
.output
,
ImageFormat
::
Png
)
.map_err
(
anyhow
::
Error
::
from
)
}
Args
::
Remap
(
remap
)
=>
{
let
image_data
=
load_image
(
&
remap
.input
,
None
)
?
;
let
palette_data
=
load_image
(
&
remap
.palette
,
None
)
?
;
let
image_palette
=
Palette
::
extract_from
(
&
image_data
)
?
;
let
target_palette
=
Palette
::
extract_from
(
&
palette_data
)
?
;
let
mappings
=
Palette
::
calculate_mapping
(
&
image_palette
,
&
target_palette
);
let
output
=
Remap
::
remap_image
(
image_data
,
mappings
)
?
;
output
.save_with_format
(
&
remap
.output
,
ImageFormat
::
Png
)
.map_err
(
anyhow
::
Error
::
from
)
}
//
Args::Remap(remap) => {
//
let image_data = load_image(&remap.input, None)?;
//
let palette_data = load_image(&remap.palette, None)?;
//
//
let image_palette = Palette::extract_from(&image_data)?;
//
let target_palette = Palette::extract_from(&palette_data)?;
//
//
let mappings = Palette::calculate_mapping(&image_palette, &target_palette);
//
let output = Remap::remap_image(image_data, mappings)?;
//
//
output
//
.save_with_format(&remap.output, ImageFormat::Png)
//
.map_err(anyhow::Error::from)
//
}
Args
::
Reduce
(
reduce
)
=>
{
if
let
Some
(
amount
)
=
reduce
.colours
{
log
::
info!
(
"Num cols {}"
,
amount
);
...
...
@@ -108,6 +108,7 @@ impl Args {
split
.run
(
&
image
)
}
Args
::
Pipeline
(
pipeline
)
=>
pipeline
.execute
(),
_
=>
Ok
(()),
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment