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

  • Home
  • SEARCH
  • 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 709929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:33:30+00:00 2026-05-14T04:33:30+00:00

We are capturing a visible tab in a Chrome browser (by using the extensions

  • 0

We are capturing a visible tab in a Chrome browser (by using the extensions API chrome.tabs.captureVisibleTab) and receiving a snapshot in the data URI scheme (Base64 encoded string).

Is there a JavaScript library that can be used to scale down an image to a certain size?

Currently we are styling it via CSS, but have to pay performance penalties as pictures are mostly 100 times bigger than required. Additional concern is also the load on the localStorage we use to save our snapshots.

Does anyone know of a way to process this data URI scheme formatted pictures and reduce their size by scaling them down?

References:

  • Data URI scheme on http://en.wikipedia.org/wiki/Data_URI_scheme
  • Chrome Extensions API on http://code.google.com/chrome/extensions/tabs.html
  • The “Recently Closed Tabs” Chrome Extension on http://code.google.com/p/recently-closed-tabs
  • 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-05-14T04:33:30+00:00Added an answer on May 14, 2026 at 4:33 am

    Here’s a function that should do what you need. You give it the URL of an image (e.g. the result from chrome.tabs.captureVisibleTab, but it could be any URL), the desired size, and a callback. It executes asynchronously because there is no guarantee that the image will be loaded immediately when you set the src property. With a data URL it probably will since it doesn’t need to download anything, but I haven’t tried it.

    The callback will be passed the resulting image as a data URL. Note that the resulting image will be a PNG, since Chrome’s implementation of toDataURL doesn’t support image/jpeg.

    function resizeImage(url, width, height, callback) {
        var sourceImage = new Image();
    
        sourceImage.onload = function() {
            // Create a canvas with the desired dimensions
            var canvas = document.createElement("canvas");
            canvas.width = width;
            canvas.height = height;
    
            // Scale and draw the source image to the canvas
            canvas.getContext("2d").drawImage(sourceImage, 0, 0, width, height);
    
            // Convert the canvas to a data URL in PNG format
            callback(canvas.toDataURL());
        }
    
        sourceImage.src = url;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 343k
  • Answers 343k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No removing them won't affect anything, unless they are being… May 14, 2026 at 5:30 am
  • Editorial Team
    Editorial Team added an answer Java does not support this. You can leverage polymorphism to… May 14, 2026 at 5:30 am
  • Editorial Team
    Editorial Team added an answer As far as I know, when accents aren't available in… May 14, 2026 at 5:30 am

Related Questions

We are designing a p2p applications using c++ which transmits voice to other peer
Is it possible to capture keyboard events within a diagram produced using Dojox.GFX? We
I'm running a regular expression against a large scalar. Though this match isn't capturing
Suppose you are using the ternary operator, or the null coalescing operator, or nested
I'm about to enter the 1st phases of designing a commodities trading application. A

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.