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

PNG / JPEG Compressor: Optimize images from a folder #259

Closed
Chixpy opened this issue Jan 25, 2022 · 1 comment
Closed

PNG / JPEG Compressor: Optimize images from a folder #259

Chixpy opened this issue Jan 25, 2022 · 1 comment
Labels
enhancement Idea of improvement of existing feature.
Milestone

Comments

@Chixpy
Copy link

Chixpy commented Jan 25, 2022

What's the Problem?

Hi, sorry if I make some mistakes in my English.

DevToys are cool, easy and amazing.

The main request is simple as: Drop/Select a folder, push a button... and all images in a folder are optimized.

I know that it's easier to say than to implement...

So, I think that it's better divide it in 3 chained subfeatures:

  1. Drop/Select a Folder.
  2. Ask if scan subfolders too.
  3. Overwrite original files
    • Optionally save a backup... (and where).

So, I know that technically they are 3 different features but I think they are close related and I don't know how to isolate them in the whole context of dropping a folder (more on Solution/Idea).

Drop/Select Folders

It could be nice if a folder can be dropped on window or selected, and then all .png/.jpg found in that folder will be added to the list. (Well, the term "added to the list" it's not what I really mean, I'll explain it in Solution/Idea section too). Selecting multiple folder at a time can be a plus, but it adds ambiguity when asking if iterate subfolders or how to make backups...

Ask for subfolders

Well, it's a easy one. Iterate over whole folder tree optimizing images, there can be some cases that we don't want to do it, so it better ask for it.

Overwrite original files (and optionally save a backup)

Well, we have a little problem here.

In the current tool workflow: Save All button asks for a folder, then optimized images are saved without any folder estructure in the selected folder. It can be usefull for individual images from the same folder; and it saves a overwrite checkbox (if want to overwrite, you select original folder; if want to keep original images, you select another folder).

But, it messes the things up if files added to the list are from different folders (but I'm not reporting it as a bug, as I see that it's inherent to the current tool workflow with indidual files and fixing it's nearly impossible without changing the workflow itself); but it's important when working with folders.

So, initially it seems that It would be "If a folder is selected/dropped keep folder structure when saving" that "Overwrite original files"; but if we want to keep original files along with compressed ones it will be tedious renaming/moving files from multiple subfolders before moving compressed files to the original ones ubication. As said before, If "selecting/dropping multiple folders at a time" is implemented can be a mess too. So i think it better, "change and make a backup" than "create new and replace"

Solution/Idea

As I said, it's easier to say that to implement...

The best way I think to handle it with a different workflow than individual files. "Adding" the files to the list waiting to be saved make the implementation much more complex (for example, if they are mixed individual files with folder ones) and it can be not clear how to handle it.

First of all, in my idea I need the next visual controls (or options), and i think they are useful for individual files too:

  • "Overwrite original files" CheckBox
    • "Make backup" preferred tri-state visual control (RadioGroup, ComboBox, etc.) with "No", "Same Folder", "Ask Folder". This control one only enabled if previous CheckBox is enabled too.

Let's go to see how I'think it would work:

  1. A folder is selected/dropped.
    • Don't follow current individual files workflow, make another one with a If/Switch/Case whatever.
  2. Ask if iterate with subfolders
  3. If (Overwrite is unchecked) or ((Overwrite is checked) and (Make backup is "Ask Folder")) then ask for an OutputBaseFolder
    • else OutputBaseFolder := InputFolder
  4. For every .png/.jpg found (going inside subfolders or not)
    • DON'T add it to the list. DON'T touch the list at all.
    1. Optimize it.
    2. Backup and Save.
      • If (Overwrite is checked) then
        • If (Make backup is "Same Folder") then copy (moving/renaming is faster) original in its folder with other name (maybe Filename_backup.png).
        • If (Make backup is "Ask Folder") then copy (moving/renaming can be faster if it's the same disc) original in OutputBaseFolder with it's subfolder structure and it's original filename.
        • Save compressed file in it original location.
      • Else (Overwrite is not checked)
        • Save compressed file in OutputBaseFolder with it's subfolder structure and it's original filename.
  5. Finished, maybe show some statistics and fireworks.

Alternatives

The main alternative I see it's a PowerShell script that iterates over the folder (and subfolders), optimize them, save in original location...; but I believe that the feature it's usefull and fantastic enough to be implemented inside the tool than make an Out-The-Box script.

As i said in Solution/Idea section, Adding the files to the list make it too much complex and it's ambiguous how to handle them when saved. So I opted for a straight forward strategy with my idea.

To be honest, the current workflow of the tool for indidual files makes difficult expand it's usefulness to folder trees.

Priorities

Capability Priority
Drop/select a folder, push a button... and all images in a folder are optimized Must
Drop/select multiple folders at a time Could
Option to load images from subfolders Should
Overwrite original files Must
Option to make backups (and where) Could

DevToys Version

Versión 1.0.1.0 | X64 | RELEASE | 3f367f1 | 3f367f1

Comments

There are many things can be more flexible or optional, but in my opinion they only will add unnecessarily complexity:

  • Selecting more than one folder at same time make a little conflict with iterating subfolders: Must we ask per folder added or only one time? I prefer last.
  • Customize how to make the backup if it's chosen to make it in same image folder (changing extension, make a subdir, etc.) with a RegEx in a TEdit.
  • Filter: Only .png / Only .jpg / Both.
  • Keep FileTime CheckBox.
  • Don't rewrite file if no change is made.
  • What to do if a file is erroneous?
  • Make Ask Folders a CheckBox instead a dialog?

As final note: In mi honest opinion, individual files should go nearly the same straightforward workflow as folders.

@veler
Copy link
Collaborator

veler commented Jan 31, 2022

Hello,

Thanks for your suggestion. We just made a change that allows users to select a folder to import in PNG / JPEG Compressor and some other tools. See #308

I will mark the current one as resolved then :)

@veler veler closed this as completed Jan 31, 2022
@veler veler added this to the v1.0.2.0 milestone Jan 31, 2022
@veler veler added the enhancement Idea of improvement of existing feature. label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Idea of improvement of existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants