Applying box-shadow to an image with a transparent background produces a rectangular shadow that traces the image file dimensions rather than the actual visible subject, which immediately looks broken to any viewer who can see both the cutout shape and the box halo behind it.
Loading Shadow Effect Builder…
Generates filter: drop-shadow() that follows PNG transparency
Live preview showing shadow wrapping the actual image outline
Controls for offset, blur, and colour with alpha
Free browser-based with no upload required
Drop the Shadow Effect Builder into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/css-tool/shadow-effect-builder?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Shadow Effect Builder by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
The CSS box model treats every element as a rectangle regardless of the visual content it contains, which is the root cause of the problem. When you apply box-shadow to an img element containing a transparent PNG, the shadow renders around the img element's full dimensions, meaning the full declared width and height of the image file including every transparent pixel along the edges. A star-shaped PNG icon against a transparent background receives a rectangular shadow with sharp corners that clearly show the file boundary instead of the star silhouette. For product photography, icon libraries, illustrated characters with organic outlines, and any cutout artwork, this rectangular shadow immediately looks wrong because the viewer can plainly see that the shadow does not match the subject they are looking at.
The filter: drop-shadow() function solves this problem by operating at the composited pixel level rather than at the box model level. After the browser has rendered the image including its alpha channel transparency, the drop-shadow filter calculates which pixels are non-transparent based on the alpha values, and creates a shadow based on those pixels' actual outlines. The result is a shadow that follows the exact visible boundary of the image content, wrapping around cutout edges, following curved outlines, correctly ignoring transparent corners, and respecting interior holes such as letterforms in logo PNGs. The syntax is filter: drop-shadow(offsetX offsetY blur colour), which is intentionally similar to box-shadow but without support for spread or inset values.
Combining drop-shadow with hover effects creates powerful image interaction states for product galleries, portfolio grids, and editorial features. Animating filter: drop-shadow() from a neutral grey shadow at rest to a coloured glow on hover changes both the shadow character and the implied atmosphere around the image at the same time. A product photo that shifts from a soft dark directional shadow to a warm orange glow on hover feels deliberately crafted rather than mechanically interactive. The drop-shadow continues to follow the image outline accurately in both states, so the animated transition looks natural and shape-aware rather than rectangular. Add transition: filter 0.2s ease to the img element to interpolate smoothly between shadow states without any jank.
Browser support and performance for filter: drop-shadow are mature and reliable across modern engines, but there are still practical limits worth knowing. The filter runs on the GPU during compositing and is generally cheap, but very large images, heavy blur radius values, and many simultaneous drop-shadow elements scrolling at once can combine to produce visible jank on lower-end mobile devices. Keep blur radius modest, typically under 16 pixels for product photography, and avoid applying drop-shadow to every image on a long-scrolling page. Reserve the effect for hero images, primary product photos, and critical visual elements where the shape-following shadow genuinely improves the design rather than treating it as a global default for every img on the site.
Adjust offset, blur, and colour in the builder and confirm the preview shows the shadow following the image content rather than the bounding box. Copy the filter CSS when the shadow wraps the image correctly.
Step-by-step guide to css shadow on image generator:
Confirm the image has a transparent background
Check that your PNG, WebP, or SVG file actually has a transparent alpha background in an image editor before applying drop-shadow. The filter only follows non-transparent pixels, so applying it to a JPEG or any image with a solid coloured background simply produces a rectangular shadow identical to box-shadow with no visual benefit. If the background is not transparent, return to the image source file and remove the background, or pick a different image, before continuing.
Set offset and blur for the shadow direction
Set horizontal and vertical offset values to position the shadow directionally beneath and to one side of the visible subject. Adjust blur radius to control the softness of the shadow edge. For product photography a low blur value in the 4 to 8 pixel range produces a crisp studio-style shadow, while higher blur values up to 20 pixels produce a softer ambient glow that suits illustration and editorial contexts. Verify the result in the live preview before committing to specific values.
Choose shadow colour and opacity
Select a shadow colour appropriate to the background colour the image will ultimately sit on in production. Use lower opacity values around rgba(0,0,0,0.18) for subtle natural-looking product shadows on white or light backgrounds. Use higher opacity or saturated coloured shadows for more dramatic editorial effects on darker or coloured page sections. Test against the actual page background colour rather than the tool default preview to avoid surprises after deployment when the shadow turns out too faint or too heavy.
Copy the filter CSS and remove any box-shadow
Copy the generated filter: drop-shadow() declaration. Apply it to the img element in your stylesheet and crucially audit the surrounding CSS to remove any existing box-shadow rule on the same element, on parent components that might cascade, or on any global img selector. Leaving a stray box-shadow in place will produce the double-shadow artifact described in the pro tips section. Test the final result in the browser on the actual page where the image will be displayed to confirm the shadow renders cleanly.
Common situations where this approach makes a real difference:
Product photography on an e-commerce product page
An e-commerce developer displays product photos with white or transparent backgrounds across category pages and product detail views. Box-shadow on these images produces an obvious rectangular outline around each photo that breaks the otherwise carefully styled product presentation. Switching to filter: drop-shadow(4px 6px 10px rgba(0,0,0,0.18)) makes the shadow wrap each product silhouette accurately, giving every product a natural studio-shadow appearance that feels physically placed on the page surface and substantially improves perceived product quality across the storefront without any image retouching work.
PNG character sprite in a browser game
A browser game developer adds animated character sprites to the game canvas as PNG cutouts with transparent backgrounds. Each character needs a ground shadow beneath it to feel grounded in the scene rather than floating in a void. Using filter: drop-shadow(0 8px 6px rgba(0,0,0,0.35)) adds a directional shadow below each character that follows the exact irregular pixel outline of the sprite. This grounds the character on the floor convincingly without any visible rectangular halo around the sprite's bounding box, even as the character animates through multiple frames during play.
Brand logo on a hero section with varied background
A brand site places a transparent-background PNG logo over a full-width looping video background in the hero section of the home page. A drop-shadow with zero offset and 8 pixel blur creates a soft halo around the logo that separates it from the video content regardless of the current video frame, ensuring legibility against everything from bright sky shots to dark interior scenes. Box-shadow in the same place would show the rectangular file boundary outline, which would be visually distracting against the moving video and undermine the otherwise polished hero presentation immediately.
Illustrated character in a marketing email
A marketing team adds an illustrated character mascot PNG to an email template promoting a seasonal campaign. Filter: drop-shadow() is now widely supported in modern email clients including the major webmail providers and current desktop clients. The drop-shadow follows the character's hand-drawn organic outline, adding subtle depth to the illustration that makes it pop against the email background. The box-shadow alternative would look obviously awkward with the organic character shape against the surrounding template background, undermining the warm hand-illustrated feel the design team is trying to communicate.
Use this when you need to add a shadow to a PNG with a transparent background, a product photo cutout, or an SVG illustration where box-shadow would produce an incorrect rectangular halo.
Get better results with these expert suggestions:
Combine drop-shadow with object-fit for responsive images
When using responsive images with object-fit: cover or object-fit: contain, the drop-shadow filter applies to the rendered pixel output after object-fit cropping has already taken place. This means the shadow always wraps the visible image content as it appears in the layout, even as the image dimensions and crop change at different viewport sizes. The behaviour is exactly what you want for art-directed responsive imagery and is one of the strongest practical reasons to standardise on drop-shadow over box-shadow for any image that uses object-fit anywhere in the responsive image system.
Use drop-shadow on :hover for coloured lighting effects
Applying different drop-shadow colours and blur values in resting and hover states simulates physically changing the lighting on an image as the cursor approaches it. A product photo that shifts from filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)) at rest to filter: drop-shadow(0 4px 16px rgba(255,100,0,0.5)) on hover creates a warm coloured glow effect that follows the product silhouette and feels deliberately atmospheric. Pair the colour shift with a small transform: translateY(-2px) to add a subtle lift, and the combined treatment becomes one of the most satisfying product card hover patterns available in pure CSS.
Chain with brightness filter for an integrated polished look
Chaining drop-shadow with brightness in a single filter declaration, for example filter: brightness(1.05) drop-shadow(0 4px 8px rgba(0,0,0,0.2)), subtly brightens the rendered image pixels and then adds a shadow based on the brightened output, all in one property. The brightness filter is applied first in the chain, then drop-shadow processes the brightened result. This combination gives images a subtly studio-treated polished appearance that elevates ordinary product photography without requiring any retouching work in an image editor before upload to the site.
Remove box-shadow entirely when switching to drop-shadow
Combining box-shadow and filter: drop-shadow() on the same img element produces two visible shadows simultaneously: a rectangular halo from box-shadow tracing the element box, and a shape-following shadow from the filter tracing the alpha channel. The result is a double-shadow artifact that looks broken and tells the viewer the page was authored carelessly. Always remove box-shadow completely when adding drop-shadow on images with transparent backgrounds, and audit your component CSS to catch any inherited or cascaded box-shadow rules that might be applied from parent selectors and creating the conflict.
Always use filter: drop-shadow() on transparent PNGs
If your image has a transparent background, drop-shadow is mandatory. Box-shadow will visibly show the rectangular file boundary. Drop-shadow follows the actual pixel outline. This difference is immediately obvious to any visitor.
Keep blur low for sharp product photo shadows
Product photos often look best with 4-8px blur to suggest a real studio shadow. Very high blur values (20px+) look like a glow rather than a shadow on detailed photo content.
Test the image on both light and dark backgrounds
Drop-shadows on transparent images look very different on different background colours. A dark shadow barely visible on a white background may be too heavy on a light grey background. Always preview on your actual page background.
More use-case guides for the same tool:
Open the full Shadow Effect Builder — free, no account needed, works on any device.
Open Shadow Effect Builder →Free · No account needed · Works on any device