CommunityToolkit/WindowsCommunityToolkit

ImageCropper, SaveAs with BitmapFileFormat.Png seems like not PNG file but bitmap

Open

#3237 aperta il 14 apr 2020

Vedi su GitHub
 (7 commenti) (0 reazioni) (0 assegnatari)C# (1403 fork)batch import
bug :bug:good first issuehelp wanted

Metriche repository

Star
 (5708 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Describe the bug

A clear and concise description of what the bug is.

  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:

I have several PNG files (Android snapshots, 600x1024 pixels, with size about 400 kB. After cropping to about 300x350 pixels, and using imageCropper.SaveAs(.., BitmapFileFormat.Png) file size is almost same, and should be much smaller. When I open such cropped file in Microsoft Imaging Suite Editor, and save as new PNG file, file size is four..five times smaller.

When I use ImageMagick to simply open/save (no edits): magick convert Screenshot_20200413-223246.png magScreenshot_20200413-223246.png file size is reduced from 452 KiB to 118 KiB.

Seems like imageCropper.SaveAs saves pixels in PNG but as bitmap, without any compression (should use deflate, as stated in PNG format description).

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

NuGet Package(s): 
6.0.0
Package Version(s): 

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [X] second 2019 Update (18363)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [X] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ ] Insider Build (xxxxx)

Device form factor:
- [X] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [X] 2019 (version: 16.4.2 ) 
- [ ] 2019 Preview (version: )

Additional context

Add any other context about the problem here.

Guida contributor