Repository navigation
feat(cli): support non-square source images in tauri icon - #15620
Conversation
Package Changes Through 4c348e5There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-build with minor, tauri-macos-sign with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor, @tauri-apps/api with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
`tauri icon` rejected any source whose width and height differ. Add a `--fit` option, modeled on the CSS `object-fit` property, to square a non-square source before generating icons: - `cover`: scale to fill the square, center-cropping the longer side - `contain`: scale to fit inside the square, padding the shorter side with transparency SVG sources are rasterized at their native size before fitting. Non-square sources without `--fit` still error, now with a hint pointing to the flag. closes tauri-apps#15376
82be280 to
5b7b424
Compare
|
@Legend-Master good catch. |
Keep SVG sources as a vector tree through the fit step and apply the crop/pad as a transform when rendering each target size, instead of rasterizing once at a fixed floor and squaring the bitmap. Icons are now rendered directly from the vector at their final resolution, so a source with a small intrinsic size stays crisp and the MIN_SVG_RASTER_SIZE upscale hack is gone.
Closes #15376.
tauri iconerrored on any source whose width and height differ (Source image must be square). This adds a--fitoption, modeled on the CSSobject-fitproperty, to square a non-square source before the existing icon pipeline runs:cover— scale to fill the square, center-cropping the longer side (may clip content)contain— scale to fit inside the square, padding the shorter side with transparencySVG sources are rasterized at their native size before fitting (square SVGs keep their vector path unchanged). A non-square source without
--fitstill errors, now with a hint pointing to the flag.Test
fit_to_squarecovering both modes (square output dimensions, center-crop stays opaque, contain padding is transparent).tauri iconon an 80x40 PNG: no--fiterrors with the hint;--fit coverand--fit containboth produce a full square icon set (icon.png512x512,icon.ico, etc.).