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

Partial JPEG recompression #1

Closed
kamemak opened this issue Apr 7, 2022 · 10 comments
Closed

Partial JPEG recompression #1

kamemak opened this issue Apr 7, 2022 · 10 comments

Comments

@kamemak
Copy link

kamemak commented Apr 7, 2022

I saw @nicolas-raoul post about partical JPEG recompression.
I think Jpegcoll is one of the solution for your requirement.
If you are interested in another lossless operations, you should check Betterjpeg.

Almost apps which have JPEG lossless operations are based on IJG code.
These apps are listed here.
But these apps have only rotate, flip and crop as lossless operation except above two probably.

@nicolas-raoul nicolas-raoul changed the title Partical JPEG recompression Partial JPEG recompression Apr 8, 2022
@nicolas-raoul
Copy link
Contributor

@kamemak

Thanks a lot for these wonderful tips! I do not have any Windows computer (only Linux & Mac), so I can not try them, but they look very promising. Indeed it looks like both can be used to retouch a part of an image without recompressing the rest of the image, which means they are usable for blurring.

Actually, my goal is to make users of the Wikimedia Commons app (the official app to upload pictures to Wikipedia/etc) avoid losing JPEG quality when uploading pictures.

I just edited the app's documentation to suggest them to use your app JPEG Cropper.

How about adding a partial blurring feature to JPEG Cropper? That feature could make your app popular among Wikipedia uploaders :-)

@kamemak
Copy link
Author

kamemak commented Apr 9, 2022

I had implemented blur like operation exprimentaly.
Please check AJT which is porting of JPEGTran to Android GUI.
The operation is hard to find, check the following step figure.

AJT_Pexlization

Curently the implementation is not practical for using.
But isn't it roughly suitabable for your requirement?

@nicolas-raoul
Copy link
Contributor

Thank you for the great tip!
AJT is very powerful.
Did you manage to use the jpegtran in Android's source code? Or are you using JNI? If you agree, I encourage you to upload AJT's source code to GitHub. 🙂

I added AJT to https://github.com/lossless-jpg/data and https://commons-app.github.io/docs.html.

By the way, I noticed a few things that might be improved in this otherwise perfect app:

  • defalutdefault
  • exitstexists
  • roraterotate
  • How about implementing an intent, so that I can "share" a picture to AJT, and it gets automatically selected as the input?

People upload a lot of pictures to Wikipedia with lots of faces to blur (example), I am not sure they will have the patience to run AJT to pixelize each face, unfortunately. 😅 I think blurring could be worth its own app, with:

  • Configurable grain size.
  • Ability to blur several areas without having to save→open→save→open→save many times.

@kamemak
Copy link
Author

kamemak commented Apr 12, 2022

Yes, I agree with your two points of improvement.
AJT is old and has a poor UI, so a new app for pixelization should be developed.
I will consider it.
Please wait patient.

@kamemak kamemak closed this as completed Apr 12, 2022
@nicolas-raoul
Copy link
Contributor

I am glad to hear that you are willing to consider it.
In any case, please feel free to comment here at any time, for instance if you find interesting apps, or if you release any new app, or if you find or write anything related to lossless. 🙂

@kamemak
Copy link
Author

kamemak commented May 8, 2022

As a 1st step, I released this repository.
The repository contains example code for Android application uses Jpegtran.
I hope this makes lossless retouch application can be developed easily.

Pixelization operation is included in the library, but size is 8x8 only, and execute once currently.

As a 2nd step, I released this repository to modify the above.
This extended Jpegtran can execute pixelization with multi sizes muliti times in a call.

Next step, easy-to-use, light GUI is needed.
I will consider it.
If you like, please develop GUI yourself.

Example of pixelization

Original image

DSC05297_

Specified options

jpegtran.exe -optimize -pix 240x240+0+384 -pix 240x240+320+128@3@3 -pix 240x192+464+384@2@1 -pix 480x320-128-64@8@8 input.jpg output.jpg

Pixelized image

Pixelization size is variable and a rectangle can be specified.
DSC05297__

Difference image

50% gray is same pixel.
The color changes from 50% gray in proportion to the difference.
DSC05297diff

@nicolas-raoul
Copy link
Contributor

Wonderful!
Thank you so much for the two GitHub projects, that is very generous of you, and extremely helpful. I started making plans to integrate your code directly into the Wikimedia Commons app (probably as a library). :-)

@kamemak
Copy link
Author

kamemak commented May 10, 2022

I created this branch which is merged 'jpegtran_extension' features.
Multi-sized pixelization could be executed on my Android simulator.
Please refer to this if you like.

If you want to modify the original IJG code to create a your own library, please refer to the following files.
The essense of pixelization is implemented only in these files.

  • transupp.c
  • transupp.h
  • jpegtran.c (ajpegtran.c)

The pxelization option -pix WxH+X+Y@N@Ma is difficult to understand, I think.
I will describe about it.

@kamemak
Copy link
Author

kamemak commented Jun 11, 2022

@nicolas-raoul

I released a new version of JpegCropper on PlayStore.
A new operation 'Pixelate' is implemented.
You can pixelate up to 16 areas and change coordinate and pixelate size with real time preview.
Please check it.

@nicolas-raoul
Copy link
Contributor

Wonderful! :-)
It seems to work great: https://github.com/lossless-jpg/data/blob/main/samples/JPEG-Cropper/blurred_comparison.jpg
The UI felt very pleasant to use, and I really appreciate the ability to choose the granularity (rough/fine).

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

No branches or pull requests

2 participants