Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Question for Color Change #221

Closed
Mikachu2333 opened this issue May 31, 2024 · 7 comments
Closed

[Feature]: Question for Color Change #221

Mikachu2333 opened this issue May 31, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@Mikachu2333
Copy link
Collaborator

Mikachu2333 commented May 31, 2024

Description

Original

Here is a pic and the lips of the character are pink.
图片

Original pic: 1717128900569_u.zip

Test MOZJPEG

Use moz mode and only -q option was changed, all other options have been set to the optimal value of not interfering with original colors.

./_rimage.exe moz 1717128900569_u.jpg -q 90 --resize \@0.5 --quantization 100 --dithering 100 - s _ued

As you can see, the lips' color of the character has changed to pale.

图片

Test PNG

Use png mode and only -q option was changed, all other options have been set to the optimal value of not interfering with original colors.

./_rimage.exe png 1717128900569_u.jpg -- -q 90 --resize "@0.5" --quantization 100 --dithering 100

No change compared to the original one.
图片

Test Squoosh

All options are setted as default (expect resize to 50%) and color doesn't be changed.
图片

Problem or Motivation

After testing other format, I've noticed that it seems that only png and other loss-less format could preserve the original color (pink) of the character's lips...

Is this my mistake in operation, or is it just the limitation of the algorithm itself, or is it an error caused by the Rimage when transform the codec?

Expected behavior

Preserve the original color.

@Mikachu2333 Mikachu2333 added the enhancement New feature or request label May 31, 2024
@SalOne22
Copy link
Owner

SalOne22 commented Jun 1, 2024

Could you also provide logs with RUST_LOG=trace env variable set?

@Mikachu2333
Copy link
Collaborator Author

Mikachu2333 commented Jun 1, 2024

moz

./_rimage.exe moz 1717128900569_u.jpg -q 90 --resize "@0.5" --quantization 100 --dithering 100 - s _ued

 DEBUG zune_jpeg::color_convert > Using AVX optimised color conversion functions
 DEBUG zune_jpeg::idct          > Using vector integer IDCT
 DEBUG zune_jpeg::color_convert > Using AVX optimised color conversion functions
 TRACE zune_jpeg::decoder       > Image encoding scheme =`Baseline DCT`
 TRACE zune_jpeg::headers       > Image width  :7680
 TRACE zune_jpeg::headers       > Image height :4320
 TRACE zune_jpeg::headers       > Image components : 3
 TRACE zune_jpeg::components    > Component ID:Y        HS:2 VS:2 QT:0
 TRACE zune_jpeg::components    > Component ID:Cb       HS:1 VS:1 QT:1
 TRACE zune_jpeg::components    > Component ID:Cr       HS:1 VS:1 QT:1
 TRACE zune_jpeg::headers       > Ss=0, Se=63 Ah=0 Al=0
 TRACE zune_jpeg::decoder       > Input colorspace YCbCr
 TRACE zune_jpeg::decoder       > Headers decoded!
 TRACE zune_jpeg::decoder       > Headers decoded!
 TRACE zune_jpeg::mcu           > Finished decoding image
 TRACE rimage::cli::pipeline    > setup resize @0.5 on index 5
 TRACE rimage::cli::pipeline    > setup quantization 100 on index 7
 WARN  rimage::cli::pipeline    > No operation found for premultiply at index 21

 TRACE zune_image::pipelines    > Current state: Decode

 TRACE zune_image::pipelines    > Finished decoding in 0 ms

 TRACE zune_image::pipelines    > Current state: Operations

 TRACE zune_image::pipelines    > Running Auto orient
 TRACE zune_image::pipelines    > Finished running `Auto orient` in 0 ms
 TRACE zune_image::pipelines    > Running apply srgb profile
 WARN  rimage::operations::icc  > No icc profile in the image, skipping
 TRACE zune_image::pipelines    > Finished running `apply srgb profile` in 0 ms
 TRACE zune_image::pipelines    > Running fast resize
 TRACE zune_image::pipelines    > Finished running `fast resize` in 50 ms
 TRACE zune_image::pipelines    > Running Colorspace conversion
 TRACE zune_image::pipelines    > Finished running `Colorspace conversion` in 1 ms
 TRACE zune_image::pipelines    > Running quantize
 TRACE zune_image::pipelines    > Finished running `quantize` in 720 ms
 TRACE zune_image::pipelines    > Finished operations for this workflow

png

./_rimage.exe png 1717128900569_u.jpg -- -q 90 --resize "@0.5" --quantization 100 --dithering 1 00

 DEBUG zune_jpeg::color_convert > Using AVX optimised color conversion functions
 DEBUG zune_jpeg::idct          > Using vector integer IDCT
 DEBUG zune_jpeg::color_convert > Using AVX optimised color conversion functions
 TRACE zune_jpeg::decoder       > Image encoding scheme =`Baseline DCT`
 TRACE zune_jpeg::headers       > Image width  :7680
 TRACE zune_jpeg::headers       > Image height :4320
 TRACE zune_jpeg::headers       > Image components : 3
 TRACE zune_jpeg::components    > Component ID:Y        HS:2 VS:2 QT:0
 TRACE zune_jpeg::components    > Component ID:Cb       HS:1 VS:1 QT:1
 TRACE zune_jpeg::components    > Component ID:Cr       HS:1 VS:1 QT:1
 TRACE zune_jpeg::headers       > Ss=0, Se=63 Ah=0 Al=0
 TRACE zune_jpeg::decoder       > Input colorspace YCbCr
 TRACE zune_jpeg::decoder       > Headers decoded!
 TRACE zune_jpeg::decoder       > Headers decoded!
 TRACE zune_jpeg::mcu           > Finished decoding image
 WARN  rimage::cli::pipeline    > No operation found for premultiply at index 13

 TRACE zune_image::pipelines    > Current state: Decode

 TRACE zune_image::pipelines    > Finished decoding in 0 ms

 TRACE zune_image::pipelines    > Current state: Operations

 TRACE zune_image::pipelines    > Running Auto orient
 TRACE zune_image::pipelines    > Finished running `Auto orient` in 0 ms
 TRACE zune_image::pipelines    > Running apply srgb profile
 WARN  rimage::operations::icc  > No icc profile in the image, skipping
 TRACE zune_image::pipelines    > Finished running `apply srgb profile` in 0 ms
 TRACE zune_image::pipelines    > Finished operations for this workflow

@SalOne22
Copy link
Owner

SalOne22 commented Jun 1, 2024

Ok I see where the problem now. Could you remove -- and move input to the end on your png args, this issue can be related to #220. Color change here is probably because of transition to rgba colorspace. Png doesn't have quantisation enabled, so no changes in color. Quantisation is a process of reducing color palette, so it's okay for it to change output colors.

@Mikachu2333
Copy link
Collaborator Author

Color change here is probably because of transition to rgba colorspace. Png doesn't have quantisation enabled, so no changes in color. Quantisation is a process of reducing color palette, so it's okay for it to change output colors.

The Quantisation would be processed although I set the parm --quantization 100? If so, is there any way to avoid it?

And, maybe this feature (just assume it's not a bug) should be invoked in the #200 to make users know what might happen.


PNG

I moved it, but still got an error for arg wrong.

./_rimage png -q 90 --resize "@0.5" --quantization 100 --dithering 100 -s "_ued" 1717128900569_u.jpg

error: unexpected argument '-q' found                                                                                     

  tip: to pass '-q' as a value, use '-- -q'

Usage: _rimage.exe png [OPTIONS] <FILES>...

For more information, try '--help'.

@SalOne22
Copy link
Owner

SalOne22 commented Jun 2, 2024

./_rimage png -q 90 --resize "@0.5" --quantization 100 --dithering 100 -s "_ued" 1717128900569_u.jpg

png command doesn't accept quality option

UPD: This is issue is only about color change that happens when using quantization. I suggest moving discussion about arguments here #220

@Mikachu2333
Copy link
Collaborator Author

png command doesn't accept quality option

?! I've been using this -q parameter without any error or warning messages so far form your first release 🤣 ...

It's necessary to add it to the readme...

@Mikachu2333
Copy link
Collaborator Author

This is issue is only about color change that happens when using quantization.

TBH, I don't know the exact reason of this issue, but since you mentioned it, I agree to move this issue.

After all, I'm just a Rust beginner. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants