Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:22:17+00:00 2026-06-03T16:22:17+00:00

How to get all the images, after decoding if possible, on a webpage through

  • 0

How to get all the images, after decoding if possible, on a webpage through XPCOM ?

The image might be specified in HTML as a background url in some CSS property, inside img tag, or in any form that a web developer might have included.

I tried looking into imgIContainer, imgIDecodeObserver and many other interfaces. Although there is a way through which we can provide image URI to Mozilla so that it loads the image, decodes it and returns imgIContainer. But I couldn’t find anyway to get all images in current webpage.

This has to be done in either Java or Javascript.

Any suggestions?


@Wladimir – Thanks for your help.

I want all the images including CSS constructs (background images). So now I am listening to events from nsIWebProgressListener.


    onStateChange: function(webProgress, request, stateFlags, status) {
        if ((~stateFlags & (nsIWebProgressListener.STATE_IS_REQUEST | nsIWebProgressListener.STATE_STOP)) == 0) {
            var imgReq = request.QueryInterface(CI.imgIRequest);
            if (imgReq)
                var img = imgReq.image;
        }
    }

The problem is that request.QueryInterface(CI.imgIRequest) throws exception for all NON-image requests. Although those exceptions can be ignored by putting code inside try-catch block, but I’d prefer to do things cleanly.

Is there any condition that can be checked to know whether request is for image or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:22:20+00:00Added an answer on June 3, 2026 at 4:22 pm

    There is existing code that you can look at. The Page Info dialog has a Media tab that successfully shows most images on the page. The important function is grabAll() in pageInfo.js, it is called for each element (via a TreeWalker). As you can see, there is no generic way to get the image, this function rather uses window.getComputedStyle() to extract the values of a bunch of the CSS properties for this element: background-image, border-image, list-style-image, cursor. It will also look for <img>, <svg:image>, <link> (favicon), <input>, <button>, <object> and <embed> tags. It doesn’t manage to recognize everything however, e.g. these CSS constructs will not be recognized:

    .foo:before
    {
      content: url(image.png);
    }
    .foo:hover
    {
      background-image: url(image.png);
    }
    

    Still, this is probably as far as you can get – unless you want to look at the requests made by the web page as it loads.

    Edit: If you look at the requests as they are performed (via a web progress listener), you can do the following:

    if (request instanceof CI.imgIRequest)
      var img = request.URI.spec;
    

    Note that request.image won’t help you much, almost all methods of imgIContainer are only accessible from native code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want after i shuffle a list of images to get all the alt=
I am trying to get all the images with class front and display their
I would like to decompile a .swf file and get all the images from
I'm trying to get the number of all images stored in the SD, but
I'm trying to get the source attribute of all images withing a specific div
I figured out how to get all the user's images in the camera roll
I noticed that almost all email messages I get do not embed images, but
I have an satellite image and I want to get all greens area. In
I'm trying to wait and then get a message when all images in an
I'm pulling images into a document via json/ajax. After they get pulled in, I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.