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

File size increase #15

Open
Tralapo opened this issue Jun 3, 2021 · 3 comments
Open

File size increase #15

Tralapo opened this issue Jun 3, 2021 · 3 comments
Labels
question Further information is requested

Comments

@Tralapo
Copy link

Tralapo commented Jun 3, 2021

I've been experimenting with this tool, it works amazing. I'm testing deface to run on jpg images downloaded from a webcam.

I noticed quite a file size increase on these jpg's:
Original: 435kb
Deface: 610kb - without any faces in the picture

Although it doesn't look like much, I'm planning on using this on quite a scale, which makes the total increased data storage quite large and I would like to avoid that where possible.

Any ideas what might increase the file size, even without faces on them?

@mdraw
Copy link
Member

mdraw commented Jun 17, 2021

To save the resulting image it has to be completely re-encoded, so both size changes and a slight drop in image quality can be expected.

The relevant code line for saving anonymization results to new images is here:

imageio.imsave(opath, frame)

imsave() is an alias to imwrite, which is documented at https://imageio.readthedocs.io/en/stable/userapi.html#imageio.imwrite.
Here you see that you can pass image format-specific options through the **kwargs, e.g. for .jpg see here: https://imageio.readthedocs.io/en/stable/format_jpeg-pil.html#parameters-for-saving

For decreasing the output file sizes, I would try lowering the quality setting to something lower than 75.

Can you change the line referenced above to something like

imageio.imwrite(opath, frame, optimize=True, quality=50)

and report if it works?

We can also make this configurable through a command line flag similar to the --ffmpeg-config option, which already exists to control video output codec options.

@Tralapo
Copy link
Author

Tralapo commented Jul 14, 2021

Sorry, I see I forgot to reply.
For now I decided not to go ahead with this package. Although it would be great to make it more easily configurable, as the file size difference is quite big.

@mdraw mdraw added the question Further information is requested label Jun 7, 2022
@frankenstein91
Copy link

@mdraw maybe a option to run the images through https://github.com/tjko/jpegoptim or http://optipng.sourceforge.net/ would be great.

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

No branches or pull requests

3 participants