DevToys icon indicating copy to clipboard operation
DevToys copied to clipboard

JPG Compressor doesn't work

Open StarHamster opened this issue 1 year ago • 1 comments

Current behavior

I select an image I want to compress and the process ends immediately with 0.00%.

Expected behavior

The image should be compressed.

Screenshots

image

Affected platforms

Windows

Affected DevToys kind

DevToys (app with GUI)

DevToys Version

Version 1.0.13.0 | X64 | RELEASE | 2706c6c2 | 2706c6c2

StarHamster avatar Jan 12 '24 06:01 StarHamster

JPG Compressor doesn't work

https://github.com/veler/DevToys/issues/1024

Current behavior I select an image I want to compress and the process ends immediately with 0.00%.

Expected behavior The image should be compressed.

Affected platforms Windows

Affected DevToys kind DevToys (app with GUI)

Potential Causes of the problem

The JPG compressor tool is designed to reduce the file size of images by compressing them. The tool's workflow involves selecting an image file, which is then processed by the PngJpgCompressorService. This service uses an external compression tool (ECT) to compress the image and returns the result. If the compression process ends immediately with a 0.00% reduction, it could be due to several reasons:

  • The image is already compressed to a level where no further compression is possible without loss of quality.
  • There might be an issue with the external compression tool not being called correctly.
  • The file path provided to the compression service might be incorrect or the file might not be accessible.
  • There could be a bug in the handling of the compression result, leading to an incorrect display of the compression percentage.

Implementation Plan

To address the issue reported, the following steps could be taken:

  1. Verify that the external compression tool is installed and accessible by the PngJpgCompressorService.
  2. Check the PngJpgCompressorWorkMessage to ensure that the file path is correct and the file is accessible.
  3. Review the PngJpgCompressorService process execution logic to confirm that the external tool is being called correctly and that the output is being handled properly.
  4. Add additional logging to capture the output and errors from the external compression tool to aid in debugging.
  5. Test the compressor with a variety of image files to determine if the issue is consistent across different file types and sizes.
  6. If a bug is identified in the code, implement the necessary fixes and perform thorough testing before releasing an update.

By following this plan, developers can systematically investigate the issue and implement a solution to ensure the JPG compressor tool works as expected.

ECT Installation Verification

The application verifies the installation of the Efficient Compression Tool (ECT) during the image compression process. This verification is performed in the PngJpgCompressorService class, where the application checks for the existence of the ECT executable file. The relevant code snippet is as follows:

string ectFullPath = Path.Combine(Constants.AssetsFolderFullPath, Constants.EfficientCompressionToolFileName);
Assumes.IsTrue(File.Exists(ectFullPath), nameof(ectFullPath));

If the ECT executable is not found, the application assumes that ECT is not installed and will throw an exception. This check ensures that the compression service can proceed with the compression task. If ECT is not installed, the application is designed to warn the user accordingly, prompting them to install ECT to use the JPG compressor feature.

For more details on how the application handles the ECT installation verification, refer to the PngJpgCompressorService.cs file in the source code.

Disclaimer

Hey there,

I'm Doug, I'm a SWE working on a ticket specification bot to help get folks understanding specific bugs faster We are trying to test out our product on various open source repos like this one.

Here is what our bot churned out for this ticket. If you found it helpful or have feedback just reply to this comment, I'll be watching it. Otherwise, I just hope this is helpful. Our thing isn't ready to sell yet, but you can find more info on our website: www.AI-Maintainer.com

In the meantime, I haven't been paid to write C# in a looooonnngg time and the bot still gets stuff wrong, but looking at the code this seems at least like a decent starting point. If you could give feedback good and bad I'd love you for it. I genuinely hope this is just useful though.

dschonholtz avatar Feb 12 '24 19:02 dschonholtz

Thanks for the feedback. We're temporarily removing this tool from DevToys 2.0 and will bring it back later with cross-platform support. I will close this issue for now.

veler avatar Mar 20 '24 15:03 veler