In website operation, image materials play a crucial role. Anqi CMS'sthumbThe filter makes it extremely convenient for us to handle images, especially when generating thumbnails.However, when dealing with images with transparent backgrounds (such as PNG formatted logos or icons), its behavior may confuse some users.thumbThe working mechanism of the filter, especially when combined with backend settings, can help us better utilize this feature.

UnderstandingthumbThe principle of the filter.

thumbThe filter is not as simple as resizing the image proportionally.It is an intelligent thumbnail generation mechanism, and its final effect is limited by the configuration of the 'Thumbnail Processing Method' in the 'Content Settings' of the Anqie CMS backend.This means that the same transparent background image may have completely different performances when generated as thumbnails on different background settings.thumbThe key to handling transparent background images with the filter.

Core: Thumbnail processing method and transparent background

AnQi CMS provides three main thumbnail processing methods in the "Content Settings" section of the backend, which have a decisive impact on the final presentation of transparent background images:

  1. Scale proportionally to the longest sideWhen you choose this processing method, the system will resize the original image proportionally based on the maximum thumbnail size (length or width) you set, so that the longest side matches the set size.For example, if you set the thumbnail size to 200x200 pixels and the original image is 400x800 pixels (with a transparent background), then the thumbnail will be scaled proportionally to 100x200 pixels.

    • The effect on transparent backgrounds: In this mode, the transparency of the image willbe retained.If your original image has a transparent background, the thumbnail will also be transparent.This method is suitable for those who need to maintain the original shape and transparency of the image and do not require a strict fixed aspect ratio for the thumbnail size.
  2. Trim according to the shortest edge

    • The effect on transparent backgrounds: Similar to aspect ratio scaling, this cropping method will usually alsoretain the transparency of the image.As long as the original image has a transparent background and the cropping area is not covered by non-transparent pixels, the thumbnail generated will still have a transparent background.This method is suitable for scenarios where you want the thumbnail to strictly fill a fixed size and display the content centered, such as product cover images.
  3. Fill the longest sideThis is the pattern that we need to pay special attention to.When this mode is selected, AnQiCMS will resize the original image proportionally according to the thumbnail size you set, making the longest side match the set size.whitecome to fill the remaining blank area to ensure that the thumbnail ultimately reaches the fixed aspect ratio you set.

    • The effect on transparent backgrounds: In this mode,the transparent background will be lost

the impact of image format conversion

Practical suggestions

  • For images that need to maintain transparency (such as website logos, transparent icons, etc.): It is recommended to set the thumbnail processing method to "Scale proportionally to the longest sideorTrim according to the shortest edgeThis ensures that your transparent background image remains transparent after generating thumbnails.
  • Images that need to be displayed at a fixed size and where transparency is not important, and even prefer to have a uniform background color: For example, the cover images of the article list can consider usingFill the longest sideThis ensures that all thumbnails maintain a consistent background visually.
  • Preparation before uploading an image.Ensure that your transparent background image is of high resolution and clear before uploading, so that it maintains good visual effects when scaled.

By flexibly using the "Content Settings" on the Anqi CMS backend, we can precisely controlthumbThe behavior of the filter processing transparent background images, thereby achieving the website visual effect we expect.


Frequently Asked Questions (FAQ)

  1. Why does the thumbnail of the logo with transparent background I uploaded have a white background? Answer:This is usually because you have set the 'thumbnail processing method' to 'pad by the longest side' in the 'Content Settings' of the Anqi CMS backend.This mode will fill the extra blank area of the image after scaling with white, thus covering the original transparent background.If you want to retain transparency, try changing the processing method to 'scale to fit the longest side' or 'crop to the shortest side'.

  2. Ask: How should I set it if I want the thumbnail of a transparent PNG image to remain transparent? Answer:Make sure the transparency is not lost, you need to select the thumbnail processing method to 'scale proportionally based on the longest side' or 'crop based on the shortest side' in the background 'Content Settings'.These modes respect the original image's alpha channel when generating thumbnails.

  3. Ask: Will the WebP conversion feature of Anqi CMS affect transparency? Answer:The WebP format itself supports transparency.Therefore, if your original image is a transparent PNG and WebP conversion is enabled, the generated WebP thumbnail will usually retain transparency when scaled to the longest edge or cropped to the shortest edge.However, if the "thumbnail processing method" is set to "pad to the longest edge", even if WebP is enabled, the final thumbnail background will still be filled with white, regardless of the file format.