Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Apache Wicket does not provide a general-purpose method for turning any Wicket component into bitmap pixels. A component normally renders markup as part of Wicket’s request and rendering lifecycle. The right approach depends on what you mean by “convert”: draw a new image in Java, display an existing image, encode a packaged image as Base64, or capture a browser screenshot of rendered HTML.

For Java-drawn pixels, use Wicket’s RenderedDynamicImageResource and draw with Graphics2D. If you need the visual result of a component after it has rendered in a browser, that is a separate screenshot task.

Choose the output you actually need

Your input and goal Wicket approach What you get
You have drawing instructions and want to generate pixels in Java RenderedDynamicImageResource, displayed by an Image component A dynamically generated image served as a Wicket resource
You already have an image packaged with the application PackageResourceReference passed to Image An image displayed in the Wicket page
You need a packaged image inline in HTML as Base64 ImageUtil.createBase64EncodedImage A Base64-encoded package resource, not a converted component
You need a screenshot of how a component’s HTML appears in a browser Use a browser-rendering and screenshot workflow separate from Wicket’s component API A capture of the rendered page or selected browser content

Wicket’s Image component displays image resources; it does not turn the markup produced by an arbitrary component into an image. Likewise, rendering a component into a Wicket response is not the same operation as rasterizing its result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate an image with Java drawing code

When the image can be described as shapes, text, or other drawing operations, implement a dynamic image resource and draw into the supplied Graphics2D. Wicket 9’s API describes RenderedDynamicImageResource as an on-demand image resource; its default output format is PNG. The image is not an arbitrary component snapshot, and its image state is transient when serialized and recreated as needed.

#1 Best Overall
Sale
Canon PIXMA TS6520 Wireless Color Inkjet Printer, Duplex Printing, Copier/Scanner, 1.42" OLED Display, Compact, White
  • Affordable Versatility - A budget-friendly all-in-one printer perfect for both home users and hybrid workers, offering exceptional value
  • Crisp, Vibrant Prints - Experience impressive print quality for both documents and photos, thanks to its 2-cartridge hybrid ink system that delivers sharp text and vivid colors
  • Effortless Setup & Use - Get started quickly with easy setup for your smartphone or computer, so you can print, scan, and copy without delay
  • Reliable Wireless Connectivity - Enjoy stable and consistent connections with dual-band Wi-Fi (2.4GHz or 5GHz), ensuring smooth printing from anywhere in your home or office
  • Scan & Copy Handling - Utilize the device’s integrated scanner for efficient scanning and copying operations

Example: draw a simple image

This Wicket 9-style example draws a colored circle on a transparent background and places the resource in a page. Check the exact method signatures against the Wicket version in your project before copying: the API details here are based on Wicket 9 documentation, while the official live example source is from the Wicket 10 examples site.

import java.awt.Color;
import java.awt.Graphics2D;

import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.image.resource.RenderedDynamicImageResource;
import org.apache.wicket.request.resource.AbstractResource;

public class CircleDynamicImageResource extends RenderedDynamicImageResource {
    public CircleDynamicImageResource(int width, int height) {
        super(width, height);
    }

    @Override
    protected boolean render(Graphics2D graphics, AbstractResource.Attributes attributes) {
        graphics.setColor(Color.BLUE);
        graphics.fillOval(10, 10, 80, 80);
        return true;
    }
}

// In a Wicket page or component:
add(new Image("generatedImage", new CircleDynamicImageResource(100, 100)));

The markup needs a matching component id:

<img wicket:id="generatedImage" alt="Generated blue circle" />

In the Wicket 9 API, the rendering hook is documented as render(Graphics2D, Attributes). Depending on the release, the fully qualified Attributes type and other signatures may differ; use the declaration shown by your installed dependency. The official image example uses the same general pattern of passing a dynamic image resource to new Image(...).

Adapt the drawing to the image you need

  • Set dimensions deliberately. The resource dimensions define the image canvas. Keep drawing coordinates within that canvas; otherwise content may be clipped.
  • Use Java2D operations for pixels. Set colors, fonts, strokes, and rendering hints on the supplied graphics context, then draw the text or shapes required by your use case.
  • Keep the hook focused on image generation. It receives a graphics context for drawing; it is not a hook that renders a Wicket component tree or runs browser layout.
  • Return the value required by the resource contract. The example returns true after drawing. Verify the contract and signatures for your installed Wicket release.

For complicated output that is already represented as HTML and CSS, drawing equivalent Java2D shapes may mean reimplementing layout and styling. In that case, decide whether you really need a Java-generated graphic or a browser screenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Display an existing image in a Wicket page

If your goal is simply to show an image alongside a component, use Wicket’s Image component with an appropriate resource reference or model. The official Wicket image example demonstrates package resources, model-backed resources, and dynamic resources.

Packaged image resource

For an image shipped with the application, create a PackageResourceReference pointing at the resource and pass it to Image. The component’s markup still needs the matching wicket:id.

Rank #2
Sale
Canon PIXMA TS4320 – Wireless Color Inkjet Printer with Print, Copy, Scan
  • Affordable Versatility - A budget-friendly all-in-one printer perfect for both home users and hybrid workers, offering exceptional value
  • Crisp, Vibrant Prints - Experience impressive print quality for both documents and photos, thanks to its 2-cartridge hybrid ink system that delivers sharp text and vivid colors
  • Effortless Setup & Use - Get started quickly with easy setup for your smartphone or computer, so you can print, scan, and copy without delay
  • Reliable Wireless Connectivity - Enjoy stable and consistent connections with dual-band Wi-Fi (2.4GHz or 5GHz), ensuring smooth printing from anywhere in your home or office
  • Scan & Copy Handling - Utilize the device’s integrated scanner for efficient scanning and copying operations
PackageResourceReference imageRef =
    new PackageResourceReference(MyPage.class, "images/logo.png");
add(new Image("logo", imageRef));
<img wicket:id="logo" alt="Company logo" />

Adjust the class and resource path to match where the file is packaged. This displays the existing file; it does not render another Wicket component into that file.

Encode a packaged image as Base64

ImageUtil.createBase64EncodedImage is a separate option when you specifically need a package resource encoded as Base64. Its documented input is a PackageResourceReference; it is not an API for converting an arbitrary component. The helper can throw ResourceStreamNotFoundException or IOException if the resource is missing or cannot be read, so handle those failures at the call site.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose this only when inline Base64 is genuinely useful to the consuming HTML. If the goal is an ordinary image in a Wicket page, using Image with the resource reference is the direct route.

Capture a browser screenshot of rendered Wicket HTML

A Wicket component can produce markup that a browser lays out and paints, but the Wicket component API discussed here does not establish an end-to-end browser screenshot method. Treat screenshot capture as a separate rendering boundary: the page must be rendered in a browser or browser engine before its pixels can be captured.

This distinction matters when the image must include CSS, fonts, JavaScript-driven content, browser layout, or the appearance of the complete rendered page. A Java2D resource is appropriate when you control the drawing instructions; it is not a shortcut for taking a screenshot of a Wicket component’s browser appearance. Verify any browser integration against your application’s Wicket version and deployment before relying on it.

Rank #3
HP OfficeJet Pro 8125e Wireless All-in-One Color Inkjet Printer, Print, scan, Copy, ADF, Duplex Printing Best-for-Home Office, 3 Month Instant Ink Trial Included, AI-Enabled (405T6A)
  • The OfficeJet Pro 8125e is perfect for home offices printing professional-quality color documents like business documents, reports, presentations and flyers. Print speeds up to 10 ppm color, 20 ppm black
  • PERFECTLY FORMATTED PRINTS WITH HP AI – Print web pages and emails with precision—no wasted pages or awkward layouts; HP AI easily removes unwanted content, so your prints are just the way you want
  • UPGRADED FEATURES – Fast color printing, scan, copy, auto 2-sided printing, auto document feeder, and a 225-sheet input tra
  • WIRELESS PRINTING – Stay connected with our most reliable dual-band Wi-Fi, which automatically detects and resolves connection issues
  • 3 MONTHS OF INSTANT INK WITH HP+ ACTIVATION – Subscribe to Instant Ink delivery service to get ink delivered directly to your door before you run out. After 3 months, monthly fee applies unless cancelled.

Or skip the browser setup

If the desired output is a screenshot of a publicly reachable rendered page, ScreenshotNeo provides a screenshot API. One GET request takes a URL and returns an image or PDF. See the ScreenshotNeo API documentation for request options and response details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://your-site.example/path 
  -o shot.webp

Use a URL your application makes accessible to the capture service; replace the example URL and supply your API key. This captures a web page, not an in-memory Wicket component that has no browser-accessible URL.

  • Cookie/consent banners are accepted and more than 60 known consent platforms, newsletter popups, and chat widgets are removed before capture; each step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. Response headers indicate the page verdict and whether the request was billed.
  • An MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
  • The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.

Sign up for 1,000 free screenshots a month, with no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common implementation problems

The result is HTML, not an image

That is expected when you render a normal Wicket component through the page lifecycle. Rendering markup and generating pixels are different tasks. Use a dynamic image resource for Java-drawn pixels, or a browser screenshot workflow for rendered HTML.

The component id does not match the markup

Wicket connects the Java Image component to markup through its component id. Check that the id passed to new Image(...) matches the wicket:id on the image element.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The packaged file cannot be found

Confirm the file is available at the package-relative location used by PackageResourceReference and is included in the deployed application. For Base64 encoding, a missing or unreadable package resource can surface as ResourceStreamNotFoundException or IOException.

The code does not compile against the project

Do not assume a Wicket 9 API example matches another release exactly. Inspect the RenderedDynamicImageResource declaration in the version your application depends on and adapt imports and the render-hook signature accordingly.

The output is clipped or unexpectedly empty

Check the dimensions supplied to the resource, drawing coordinates, and whether the drawing operations occur within the image canvas. Also confirm that the rendering hook completes according to the contract for your Wicket release.

Performance, reliability, and choice of approach

A dynamic resource is generated on demand, so its drawing work occurs as the image is requested. Keep drawing work proportionate to the requested image and avoid treating the resource as persistent storage for a component screenshot: the Wicket 9 API documents transient image state that is recreated when needed. If output depends on changing application data, determine how that data is made available to the resource and how your application should handle repeated requests; the API facts here do not establish a particular caching strategy or performance level.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a screenshot workflow, reliability depends on the browser-rendered page being reachable and loading the content you want captured. A Wicket page protected by authentication, an interactive session, or other access controls may require a separately configured route and must not be assumed accessible just because the application can render it for a logged-in visitor. Keep sensitive pages private and only expose capture access that your security design permits.

In short: choose a resource when the image can be generated from Java drawing code, choose a package reference to display a file, use Base64 only for an inline packaged image, and use browser capture when the required pixels are the browser’s rendering of HTML.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.