📲
PWA Bundle
1.0.x
1.0.x
  • PHPWA Bundle
  • How To Create A PWA?
  • How To Install/Remove A PWA?
  • Bundle Installation
  • Deployment
  • The Manifest
    • Application Information
      • Scope
      • ID
      • Direction and Language
      • Orientation
      • Description
      • IARC Rating ID
      • Categories
    • Icons
    • Screenshots
    • Shortcuts
    • Protocol Handlers
    • File Handlers
    • Share Target
    • Complete Example
  • The Service Worker
    • Configuration
    • Content Security Policy
    • Custom Service Worker Rule
    • Workbox
      • Site Manifest Cache
      • Asset Caching
      • Resource Caching
      • Image Caching
      • Font Caching
      • Offline Fallbacks
      • BackgoundSync
      • CDN and Versions
      • Cache Cleaning
      • Custom Cache Strategy
    • Push Notifications
    • Complete Example
  • Symfony UX
    • Connection Status
    • Prefetch on demand
    • Sync Broadcast
    • BackgroundSync Form
  • Image Management
    • Icons
    • Screenshots
  • Experimental Features
    • Non-Standard Parameters
      • Launch Handler
      • Display Override
      • Related Applications
      • EDGE Side Panel
    • Translations
    • Widgets (Win10+)
Powered by GitBook
On this page
  • Image Processor
  • Resizing Icons
  • Formats And Sizes
  • Output Folder

Was this helpful?

Edit on GitHub
Export as PDF
  1. Image Management

Icons

Progressive Web Apps may have icons of multiple formats and sizes to be correctly shown on targeted plaforms. This task may become boring as your application evolves. The bundle provides a simple console command to ease the creation of these icons.

Icons shall be square images

Image Processor

The icon command requires an image processor to work to be declared in the configuration file. Two Image Processors are provided by the bundle.

  • pwa.image_processor.imagick: requires the PHP Imagick extension

  • pwa.image_processor.gd: requires the PHP GD extension

You can use a custom service if needed. It must implement the interface SpomkyLabs\PwaBundle\ImageProcessor\ImageProcessor.

/config/packages/pwa.yaml
pwa:
    image_processor: 'pwa.image_processor.imagick'

Resizing Icons

From your shell, you can use the following command line to convert an image to a preset of sizes and using the same format as the input:

symfony console pwa:create:icons /path/to/the/image.png

This will create a folder in assets/icons with icons of sizes 16x16, 32x32, 48x48, 96x96, 144x144, 180x180, 256x256, 512x512 and 1024x1024. In addition, the console output will give you the best configuration to use these new image files by copy-pasting.

pwa:
    manifest:
        icons:
            - src: icons/icon-16x16.jpg
              sizes:
                - 16
              type: image/png
            - ...

This configuration is to be adapt depending on the icon type (application, shortcut, widget...)

Formats And Sizes

You can change the format and sizes by setting the values you need as options

symfony console pwa:create:icons /path/to/the/image.png --format="jpg" 48 96 256

Output Folder

Similarily, if you want to change the output folder, you can set it as an option.

symfony console pwa:create:icons /path/to/the/image.png --output="/foo/bar"
PreviousBackgroundSync FormNextScreenshots

Last updated 1 year ago

Was this helpful?