file_compression_plus 1.0.0
file_compression_plus: ^1.0.0 copied to clipboard
Compress images and PDFs in Flutter. Hit an exact target file size, batch compress with progress, convert JPG PNG WebP HEIC, and shrink PDF documents.
1.0.0 #
First stable release. Fixes the plugin declaration that broke consumer builds in every earlier version, and adds the features the package was missing.
Fixes #1.
Upgrading is safe. Nothing you were already calling has changed. See the migration guide.
Fixed #
- Builds no longer fail with "doesn't have a main class defined". The
pubspec.yamldeclared this package as a Flutter plugin, namingFileCompressionPlusPluginfor Android, iOS, macOS, Windows and Linux andFileCompressionPlusWebfor web. None of those classes existed. Flutter looked for them at build time and failed. This is a pure Dart package and needs no platform code, so the plugin block is gone along with the dead stubs it pointed at. - Compression can no longer hand back a file that is bigger than the one you
gave it. That happens with already optimised images and PDFs. The new
skipIfLargerflag is on by default and keeps the original instead. - PDF errors no longer collapse into a generic
Invalid PDF file formatexception that hid the real cause. A damaged document throws aFileSystemExceptioncarrying the file path. - Removed a pointless
PdfPage.graphics.save()call on every page during PDF compression. It saved graphics state and did nothing for the output size. - Removed an unnecessary copy of the source image into the temporary directory before compression. The encoder reads the source directly.
- Removed
printcalls from the library. A package should not write to the console of the app using it.
Added #
compressImageToTargetSizecompresses until the file fits a byte budget. It binary searches the quality range so you keep the highest quality that still fits, and halves the dimensions when quality alone is not enough.compressBatchcompresses a list of files with per-file progress throughBatchProgress, and collects per-file errors inBatchCompressionResultinstead of failing the whole run.compressImageBytesandcompressPdfByteswork onUint8Listwithout touching the disk, for downloaded or in-memory data.compressroutes any supported file to the image or PDF compressor by its extension, for when a picker hands you a file of unknown type.FileCompressor.canCompress,supportedExtensionsandsupportedImageExtensionsfor filtering a picker result.ImageFormat.heicfor the smallest output on devices that can write it. ThrowsUnsupportedErrorelsewhere, so catch it and fall back to JPEG.removeMetadataon the PDF methods clears title, author, subject, keywords, creator and producer.rotateon the image methods turns the image while compressing.outputPathon every method writes the result to an exact path and creates any missing parent folders.keepExifon the image methods keeps camera metadata.CompressionResultreportsoriginalSize,compressedSize,savedBytes,savedPercentage,wasSkipped,readableOriginalSizeandreadableCompressedSize.formatBytesturns a byte count into something a user can read.- Validation for
maxWidthandmaxHeight, which must be greater than zero.
Changed #
- Upgraded
syncfusion_flutter_pdffrom 28.2.7 to 34.2.4 andflutter_image_compressfrom 2.4.0 to 2.5.1.pathis now 1.9.1,path_provider2.1.6 andflutter_lints6.0.0. - Dropped
universal_ioandjs, which were never imported, and themockitoandbuild_runnerdev dependencies, whose generated mocks file was unused. - Minimum SDK raised to Dart 3.6 and Flutter 3.27.
- Corrected the repository, homepage and issue tracker links, which pointed at a GitHub account that does not host this project.
- Split the library into
lib/src/models.dartandlib/src/file_compressor.dartbehind the same single import.
Documentation #
- Rewrote the README with badges, a platform support table, a full API reference and the error behaviour.
- Added
doc/RECIPES.mdwith worked solutions for the common jobs, anddoc/MIGRATION.mdfor upgrading from 0.0.x. - Added
CONTRIBUTING.md. The project is open to contributors, get in touch at hello@tisankan.dev. - Added a GitHub Actions workflow that runs analyze, format, tests and pana on every push and pull request, plus issue templates.
- Rewrote the example app. It now demonstrates single file compression, batch compression with a progress bar, and target size compression.
Tests #
- 54 tests, all passing. The suite was previously failing 6 of 11 on every run.
- The PDF fixture is generated at run time. The committed one was not a valid PDF, which is why the PDF tests had been failing.
- Image compression tests cover argument and file checks only. The encoders are
native and cannot run in a plain
flutter testprocess, so the example app covers those paths on a real device.
0.0.5 #
- Removed web platform support to optimize package size and performance
- Enhanced native platform implementation
- Improved code documentation and examples
- Updated dependencies to latest stable versions
- Fixed platform-specific configurations
- Optimized package structure and organization
0.0.4 #
- Maintenance release
0.0.3 #
- Maintenance release
0.0.2 #
- Added comprehensive documentation and examples
- Improved error handling and resource cleanup
- Fixed platform configurations in pubspec.yaml
- Updated Flutter SDK requirement to >=1.20.0
- Added proper plugin implementation structure
0.0.1 #
- Initial release of File Compression Plus
- Added image compression functionality with customizable quality and dimensions
- Added PDF compression with multiple compression levels
- Support for JPG, PNG, and WebP image formats