google / guetzli

Perceptual JPEG encoder
Apache License 2.0
12.9k stars 976 forks source link

Same filename for input and output doesn't work #20

Closed robryk closed 7 years ago

robryk commented 7 years ago

Split away form #19. We should probably open the output file for writing first and truncate it only after we have the output JPEG ready.

khavishbhundoo commented 7 years ago

ignore or delete that commit....sorry i am new to github

khavishbhundoo commented 7 years ago

I just started learning c++ so forgive my ignorance

Check my attempt to solve the problem https://github.com/khavishbhundoo/guetzli/commit/f4c3a331b307aaf86f89fda8c589e21d99fb79ae

However i seems to get an issue in trying to get bazel to see my changes while compiling(sounds crazy and stupid)

I tried the following

Modified the error message (Guetzli processing failed) to something else and then ran bazel clean and bazel build -c opt //:guetzli.Surprising the error shown is still Guetzli processing failed

Furniel commented 7 years ago

I think we should allow optimization only with one image as argument, code will look like this: https://github.com/Furniel/guetzli/commit/5252181fa2e1d79527b4618d7569b6e07477f0e1 With this patch image optimization works with input image or with input and optput images(output can be same). That`s not final code, if we want allow use guetzli only with one arg we should check input image format. Everything works good if input image is jpg but if input is png - output will be written to png too now(that's not good idea).

robryk commented 7 years ago

@Furniel I don't want to encourage people to use the same file for input and output, because it generally creates confusion that leads to someone running an image through Guetzli twice (or more). Passing an image multiple times through Guetzli is not equivalent to passing it once, and will generate visible artifacts.