-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add option to overwrite original #20
Comments
This is a lossy optimization so I think that many/most will want to hang on to their original images for comparison. Let me see if we can work an option for overwrites into the new command line executable that is in development. We should be able to support this. |
👍 Excellent results with this tool : it can further optimize image that PNGenie had already compressed ! |
Thanks for your feedback! Will look into it. |
I have a new command line executable that is in development in #19. It supports parallel image processing on any *nix system (this will get to Linux and *nix on Win support) and the scripting will be the basis of the next version of the GUI tool. It will be simple to add this request to the command line executable. How important is it to you that this is implemented in the GUI tool as well? I am not a macOS objC/Swift developer and the GUI approach that I am using would likely involve a workaround like an environment variable or dotfile in the $HOME directory to support optional overwrites from the GUI tooling. |
Well the GUI is great to have as it makes the app easier to use. But if it's too complex then I'll switch from using GUI to command line which is slower at the end than just grabbing and dragging a bunch of files to a window |
We should be able to make it happen in the GUI. Will let you know when it is available. Thanks for the feedback. |
Hi @chrissimpkins, any progress on that? BTW great tool. Love it! ❤️❤️❤️❤️❤️ |
Thanks for the note Marcin! I am working on native macOS application chops as we speak. I am considering a rebuild of the desktop application from scratch. I will definitely look into it for both GUI and command line as soon as I circle back to this project. And it is always open for PR's! If anyone else out there wants to tackle it as an optional feature that users call explicitly, I would be happy to implement it. |
Thanks for letting me know. I'd be happy to help, but sadly, I'm not familiar with Python 😔 |
No worries! I'll do my best to get back to this soon. Time... |
If you want to modify the default behavior yourself, I believe that you should be able to do it by modifying this block beginning at line 400: Lines 400 to 410 in dee3cba
to something like the following: # report percent original file size / post file path / size (bytes) to log file (macOS GUI + right-click service)
if is_gui(sys.argv):
log_info(
"[ "
+ percent_string
+ " ] "
+ img.post_filepath
+ " ("
+ str(img.post_size)
+ " bytes)"
)
try:
os.remove(img.pre_filepath)
shutil.move(img.post_filepath, img.pre_filepath)
stdstream_lock.acquire()
print("Moved {} to {}".format(img.post_filepath, img.pre_filepath))
stdstream_lock.release()
except Exception as e:
stdstream_lock.acquire()
sys.stderr.write("Error: Unable to overwrite pre image file {}. Error message: {}".format(img.pre_filepath, e))
stdstream_lock.release() You can then rename the Please (please, please) try this on copies of files before you attempt on anything that you can't afford to lose. This is 100% untested but I think that it should work™ and is intended as a way to help anyone out there who is interested get started on a derivative that addresses this issue until I can do it upstream. |
@chrissimpkins thanks for the pointers. Following your instructions, I did some changes and made a PR #76 |
The changes from Marcin are now in the |
Just want to let you know, that this is the primary way I'd use it. I'm going to install the dev branch right now. |
Just looking at the comments on @marcinkrzeminski's PR (#76), perhaps instead of a checkbox for overwriting, some kind of contextual popup could be used? E.g. dragging files to GUI, delay for a few seconds, background of GUI changes, and when you release the mouse button, you receive an 'Are you sure?' prompt. Please excuse the rough mock-up, but something like:
I'm not sure if that's any easier than modifying the GUI, though. If the information helps: I'm going to try to use this in an image processing workflow with the Anyway, just an idea! |
Thanks for the suggestion! I really like it but it isn't possible with the current approach. The GUI is built around our scripts with an automated tool and the addition of dialogs/toasts/OK + Cancel buttons and the like are not possible. I've been giving some thought to moving this over to PyQt5 so that we have the ability to support cross-platform GUI, custom settings (including an option to always write files in place), and user-defined zopflipng/pngquant paths. Let me see when time opens up to look into this. If we keep it relatively simple, it may not be a terribly large amount of work. |
Understood - I thought that might be the case based on previous notes. For automated workflows, |
Normally I want just to compress the original exported assets so would be nice to have an "overwrite original" option
Thanks for the great work 👍
The text was updated successfully, but these errors were encountered: